当前位置: 首页>>代码示例>>C#>>正文


C# Renderer.GetComponent方法代码示例

本文整理汇总了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);
	}
开发者ID:onepenny,项目名称:manual_dota,代码行数:7,代码来源:SkeletonUtilitySubmeshRenderer.cs

示例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();
 }
开发者ID:TuckerBMorgan,项目名称:Slide,代码行数:11,代码来源:ConflictController.cs

示例3: OnEnable

	void OnEnable () {
		parentRenderer = transform.parent.GetComponent<Renderer>();
		parentRenderer.GetComponent<SkeletonRenderer>().OnReset += HandleSkeletonReset;
	}
开发者ID:onepenny,项目名称:manual_dota,代码行数:4,代码来源:SkeletonUtilitySubmeshRenderer.cs

示例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 );
	}
开发者ID:Pampattitude,项目名称:PixelPerfectCameraKit,代码行数:88,代码来源:PixelCamera2D.cs


注:本文中的Renderer.GetComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。