本文整理汇总了C#中Renderer.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.GetComponent方法的具体用法?C# Renderer.GetComponent怎么用?C# Renderer.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderer
的用法示例。
在下文中一共展示了Renderer.GetComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize (Renderer parentRenderer) {
this.parentRenderer = parentRenderer;
parentFilter = parentRenderer.GetComponent<MeshFilter>();
mesh = parentFilter.sharedMesh;
filter.sharedMesh = mesh;
Debug.Log("Mesh: " + mesh);
}
示例2: AddPulseMaterial
public void AddPulseMaterial(Renderer rend)
{
var mats = rend.sharedMaterials;
var newMats = new List<Material>();
for (var i = 0; i < mats.Length; i++)
{
newMats.Add(mats[i]);
}
newMats.Add(pulseTest);
rend.GetComponent<Renderer>().sharedMaterials = newMats.ToArray();
}
示例3: OnEnable
void OnEnable () {
parentRenderer = transform.parent.GetComponent<Renderer>();
parentRenderer.GetComponent<SkeletonRenderer>().OnReset += HandleSkeletonReset;
}
示例4: updateTexture
void updateTexture( bool forceRefresh = true )
{
if( targetCamera == null )
return;
if( _camera == null )
{
_camera = GetComponent<Camera>();
if( _camera == null )
_camera = gameObject.AddComponent<Camera>();
// one time camera setup goes here
_camera.orthographic = true;
_camera.orthographicSize = 0.5f;
_camera.farClipPlane = 2;
_camera.clearFlags = CameraClearFlags.SolidColor;
}
// variable camera setup (values copied from the target camera)
_camera.depth = targetCamera.depth;
_camera.rect = targetCamera.rect;
_camera.useOcclusionCulling = false;
_camera.backgroundColor = targetCamera.backgroundColor;
var aspectCeil = Mathf.CeilToInt( _camera.aspect );
if( forceRefresh || _texture == null )
{
if( _texture != null )
{
targetCamera.targetTexture = null;
_texture.Release();
DestroyImmediate( _texture );
}
var renderTextureFormat = RenderTextureFormat.Default;
switch( colorDepth )
{
case PixelCamera2D.ColorDepth._12bits:
renderTextureFormat = RenderTextureFormat.ARGB4444;
break;
case PixelCamera2D.ColorDepth._16bits:
renderTextureFormat = RenderTextureFormat.RGB565;
break;
case PixelCamera2D.ColorDepth._24bits:
renderTextureFormat = 0;
break;
}
_texture = new RenderTexture( pixelHeight * aspectCeil, pixelHeight, 24, renderTextureFormat );
_texture.name = "PixelCameraRT";
_texture.Create();
_texture.filterMode = FilterMode.Point;
}
targetCamera.targetTexture = _texture;
if( _quad == null )
{
// kill any child GO's in case we have a stray quad
for( var i = _transform.childCount - 1; i >= 0; i-- )
DestroyImmediate( _transform.GetChild( i ).gameObject );
_quad = GameObject.CreatePrimitive( PrimitiveType.Quad ).GetComponent<MeshRenderer>();
DestroyImmediate( _quad.GetComponent<Collider>() );
}
_quad.transform.parent = transform;
_quad.transform.localPosition = Vector3.forward;
if( customMaterial == null )
{
if( _material == null )
{
_material = new Material( Shader.Find( "Unlit/Texture" ) );
_material.hideFlags = HideFlags.DontSave;
}
}
else
{
_material = customMaterial;
}
_material.mainTexture = _texture;
_quad.sharedMaterial = _material;
_transform.position = 99999f * Vector3.down;
_transform.localScale = new Vector3( aspectCeil, 1f, 1f );
}