当前位置: 首页>>代码示例>>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;未经允许,请勿转载。