當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.Renderer類代碼示例

本文整理匯總了C#中UnityEngine.Renderer的典型用法代碼示例。如果您正苦於以下問題:C# Renderer類的具體用法?C# Renderer怎麽用?C# Renderer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Renderer類屬於UnityEngine命名空間,在下文中一共展示了Renderer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InstantiateDirectionIndicator

        private GameObject InstantiateDirectionIndicator(GameObject directionIndicator)
        {
            if (directionIndicator == null)
            {
                return null;
            }

            GameObject indicator = Instantiate(directionIndicator);

            // Set local variables for the indicator.
            directionIndicatorDefaultRotation = indicator.transform.rotation;
            directionIndicatorRenderer = indicator.GetComponent<Renderer>();

            // Start with the indicator disabled.
            directionIndicatorRenderer.enabled = false;

            // Remove any colliders and rigidbodies so the indicators do not interfere with Unity's physics system.
            foreach (Collider collider in indicator.GetComponents<Collider>())
            {
                Destroy(collider);
            }

            foreach (Rigidbody rigidBody in indicator.GetComponents<Rigidbody>())
            {
                Destroy(rigidBody);
            }

            Material indicatorMaterial = directionIndicatorRenderer.material;
            indicatorMaterial.color = DirectionIndicatorColor;
            indicatorMaterial.SetColor("_TintColor", DirectionIndicatorColor);

            return indicator;
        }
開發者ID:OpenHID,項目名稱:InteractivePaint,代碼行數:33,代碼來源:DirectionIndicator.cs

示例2: OnStart

 public override void OnStart(PartModule.StartState state)
 {
     Flap = part.FindModelTransform(flapTransform);
     cachedRenderer = Flap.gameObject.GetComponent<Renderer>();
     if (FlapActive != false)
         ToggleFlaps();
 }
開發者ID:Crzyrndm,項目名稱:ProceduralWings,代碼行數:7,代碼來源:FlapToggler.cs

示例3: SetupMaterialPropertyBlock

 public static void SetupMaterialPropertyBlock(MaterialProperty materialProp, int changedMask, Renderer target)
 {
   MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
   target.GetPropertyBlock(materialPropertyBlock);
   materialProp.WriteToMaterialPropertyBlock(materialPropertyBlock, changedMask);
   target.SetPropertyBlock(materialPropertyBlock);
 }
開發者ID:BlakeTriana,項目名稱:unity-decompiled,代碼行數:7,代碼來源:MaterialAnimationUtility.cs

示例4: MaterialCache

		public MaterialCache(Renderer renderer)
		{
			if(renderer as SpriteRenderer)
			{
				return;
			}
			
			List<Material> l_materialList = new List<Material>();
			
			foreach(Material material in renderer.sharedMaterials)
			{
				Material materialInstance = null;
				
				if(material)
				{
					materialInstance = GameObject.Instantiate<Material>(material);
					materialInstance.hideFlags = HideFlags.DontSave;
					materialInstance.shader = Shader.Find("Sprites/Default");
				}
				
				l_materialList.Add(materialInstance);
			}
			
			m_Materials = l_materialList.ToArray();
			
			renderer.sharedMaterials = materials;
		}
開發者ID:Kundara,項目名稱:project1,代碼行數:27,代碼來源:MaterialCache.cs

示例5: Awake

 protected virtual void Awake()
 {
     MeshRenderer = GetComponent<MeshRenderer>();
     Renderer = GetComponent<Renderer>();
     Collider = GetComponent<Collider>();
     ParticleSystem = GetComponent<ParticleSystem>();
 }
開發者ID:ai-ry,項目名稱:orbit,代碼行數:7,代碼來源:CachedBehavior.cs

示例6: Awake

 void Awake()
 {
     trans = GetComponent<Transform>();
     rend = GetComponent<Renderer>();
     col = GetComponent<Collider>();
     gc = GameController.Instance;
 }
開發者ID:DevelopVladimir,項目名稱:SpheresHunt,代碼行數:7,代碼來源:SphereController.cs

示例7: Start

 void Start()
 {
     bout = transform.GetChild(0).GetComponent<Renderer>();
     centre = transform.GetChild(1).GetComponent<Renderer>();
     pointe = transform.GetChild(2).GetComponent<Renderer>();
     reset();
 }
開發者ID:CanPayU,項目名稱:SuperSwungBall,代碼行數:7,代碼來源:FlecheController.cs

示例8: AttachToTarget

        /// <summary>
        /// Attaches this object to 'attachTarget' at 'point'
        /// </summary>
        /// <param name="point">Point to attach to.</param>
        /// <param name="attachTarget">Target object.</param>
        protected void AttachToTarget () {
            targetRenderer = attachTarget.GetComponent<Renderer>();
            targetBounds = targetRenderer.bounds;
            targetPosition = attachTarget.transform.position;

            float width = targetBounds.size.x;
            float height = targetBounds.size.y;
            float attachTargetX = targetPosition.x;
            float attachTargetY = targetPosition.y;
            //NOTE (aaron): Ideally this would be independent of anchor/pivot position, but I cannot find a way to abstract
            //the local relative position of this position within the object. Therefore, this currently only works for objects
            //with centered pivots.
            switch (attachPoint) {
                case AttachPoint.BottomLeft:
                    transform.position = new Vector3(attachTargetX - width / 2, attachTargetY - height / 2, 0);
                    break;
                case AttachPoint.BottomRight:
                    transform.position = new Vector3(attachTargetX + width / 2, attachTargetY - height / 2, 0);
                    break;
                case AttachPoint.TopLeft:
                    transform.position = new Vector3(attachTargetX - width / 2, attachTargetY + height / 2, 0);
                    break;
                case AttachPoint.TopRight:
                    transform.position = new Vector3(attachTargetX + width / 2, attachTargetY + height / 2, 0);
                    break;
                case AttachPoint.BottomCenter:
                    transform.position = new Vector3(attachTargetX, attachTargetY - height / 2, 0);
                    break;
                case AttachPoint.TopCenter:
                    transform.position = new Vector3(attachTargetX, attachTargetY + height / 2, 0);
                    break;
            }
        }
開發者ID:Executable-Games,項目名稱:We-Havent-Picked-A-Name,代碼行數:38,代碼來源:Attach.cs

示例9: Init

 void Init()
 {
     if (m_renderer == null) {
     m_renderer = gameObject.GetComponent<Renderer>();
     m_position = gameObject.transform.localPosition;
     }
 }
開發者ID:greggman,項目名稱:hft-unity-gamepad,代碼行數:7,代碼來源:ExampleCharacterSelectPlayer.cs

示例10: Start

        private void Start()
        {
            _rigidbody = GetComponent<Rigidbody2D>();
            _renderer = GetComponent<SpriteRenderer>();

            _controller.Jump += Jump;
        }
開發者ID:shredder2500,項目名稱:GlobalGameJam2016,代碼行數:7,代碼來源:Entity.cs

示例11: Awake

 private void Awake()
 {
     myRenderer = GetComponentInChildren<Renderer> ();
     originalTexture = myRenderer.material.mainTexture;
     SetStartPosition (startPosition);
     InitMapObjectType();
 }
開發者ID:juliancruz87,項目名稱:madbricks,代碼行數:7,代碼來源:MapObject.cs

示例12: Awake

			void Awake()
			{
				this.grid = transform.parent.parent.GetComponent<Grid> ();
				renderer = GetComponent<Renderer> ();
				randomize = false; // to set baseColor
				renderer.material.color = baseColor;
			}
開發者ID:s33hunt,項目名稱:3D-noise-world,代碼行數:7,代碼來源:Grid.cs

示例13: Start

 void Start()
 {
     r = HandTarget.GetComponent<Renderer>();
     rbd = GetComponent<Rigidbody>();
     rbd.useGravity = false;
     tossModule = GetComponent<PlayerTossModule> ();
 }
開發者ID:foundway,項目名稱:EarlyBeeAR,代碼行數:7,代碼來源:Player.cs

示例14: ExportToFile

		public static void ExportToFile(Mesh mesh, Renderer renderer, string filename, bool uselhcoords = true) {
			if (string.IsNullOrEmpty (filename))
				return;
			using (StreamWriter sw = new StreamWriter(filename)) {
				sw.Write(ExportToString(mesh, ref renderer, uselhcoords));
			}
		}
開發者ID:anteaterho,項目名稱:SpoutTestTemp,代碼行數:7,代碼來源:FbxTools.cs

示例15: ApplyMaterialModificationToAnimationRecording

        public static bool ApplyMaterialModificationToAnimationRecording(MaterialProperty materialProp, int changedMask, Renderer target, object oldValue)
        {
            switch (materialProp.type)
            {
                case MaterialProperty.PropType.Color:
                    SetupMaterialPropertyBlock(materialProp, changedMask, target);
                    ApplyMaterialModificationToAnimationRecording(materialProp, target, (Color) oldValue);
                    return true;

                case MaterialProperty.PropType.Vector:
                    SetupMaterialPropertyBlock(materialProp, changedMask, target);
                    ApplyMaterialModificationToAnimationRecording(materialProp, target, (Color) ((Vector4) oldValue));
                    return true;

                case MaterialProperty.PropType.Float:
                case MaterialProperty.PropType.Range:
                    SetupMaterialPropertyBlock(materialProp, changedMask, target);
                    ApplyMaterialModificationToAnimationRecording(materialProp, target, (float) oldValue);
                    return true;

                case MaterialProperty.PropType.Texture:
                {
                    if (!MaterialProperty.IsTextureOffsetAndScaleChangedMask(changedMask))
                    {
                        return false;
                    }
                    string name = materialProp.name + "_ST";
                    SetupMaterialPropertyBlock(materialProp, changedMask, target);
                    ApplyMaterialModificationToAnimationRecording(name, target, (Vector4) oldValue);
                    return true;
                }
            }
            return false;
        }
開發者ID:CarlosHBC,項目名稱:UnityDecompiled,代碼行數:34,代碼來源:MaterialAnimationUtility.cs


注:本文中的UnityEngine.Renderer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。