• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.Renderer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEngine.Renderer的典型用法代码示例。如果您正苦于以下问题:C# Renderer类的具体用法?C# Renderer怎么用?C# Renderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Renderer类属于UnityEngine命名空间,在下文中一共展示了Renderer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: ExportToString

		public static string ExportToString (Mesh mesh, ref Renderer renderer, bool uselhcoords = true){
#if UNITY_EDITOR
			EditorUtility.DisplayProgressBar("EJM Software FBX Exporter", "Writing header", 0f);
#endif
			string documenttext = "; FBX 6.1.0 project file\n; Copyright (C) 1997-2008 Autodesk Inc. and/or its licensors.\n; All rights reserved.\n; ----------------------------------------------------\n\n";
			documenttext += FBXHeaderExtensionNode ();
			documenttext += "\n\n; Object definitions\n;------------------------------------------------------------------\n\n";
			documenttext += DefinitionsNode (ref mesh, ref renderer).ToString();
			documenttext += "\n\n; Object properties\n;------------------------------------------------------------------\n\n";
			string skinmodelnodes = "", defnodes = "", posenode = "";
			if (renderer.GetType() == typeof(SkinnedMeshRenderer)){
#if UNITY_EDITOR
				EditorUtility.DisplayProgressBar("EJM Software FBX Exporter", "Parsing skinning data", 0.33f);
#endif
				SkinnedMeshRenderer skmr = renderer as SkinnedMeshRenderer;
				skinmodelnodes = SkinnedModelNodes(ref skmr);
				defnodes = DeformationNodes(ref mesh, ref skmr);
				posenode = PoseNode(ref mesh);
			}
#if UNITY_EDITOR
			EditorUtility.DisplayProgressBar("EJM Software FBX Exporter", "Writing mesh data", 0.66f);
#endif
			documenttext += ObjectsNode (ModelNodes (ref mesh, uselhcoords) + skinmodelnodes, MaterialNodes (ref renderer), TextureNodes(ref renderer), defnodes, posenode, GlobalSettingsNode ().ToString());
			documenttext += "\n\n; Object connections\n;------------------------------------------------------------------\n\n";
			documenttext += ConnectionsNode (ref mesh, ref renderer).ToString();
			documenttext += "\n\n;Version 5 settings\n;------------------------------------------------------------------\n\n";
			documenttext += Version5Node ();
#if UNITY_EDITOR
						EditorUtility.ClearProgressBar();
#endif
			return documenttext;
		}
开发者ID:anteaterho,项目名称:SpoutTestTemp,代码行数:32,代码来源:FbxTools.cs


示例17: UpdateMeshData

        protected override void UpdateMeshData(bool forceUpdate = false)
        {
            if (_meshRenderer == null || _meshFilter == null || IsPartOfStaticBatch)
                return;

            if (GameSpriteRenderer != null && (GameSpriteRenderer != _oldGameSpriteRenderer || forceUpdate ||
                (_oldUnitySprite != null && _oldUnitySprite.sprite != null && _oldUnitySprite.sprite != Sprite) ||
                (_oldCustomSprite != null && _oldCustomSprite.Sprite != null && _oldCustomSprite.Sprite != Sprite)))
            {
                _oldGameSpriteRenderer = GameSpriteRenderer;

                _oldCustomSprite = GameSpriteRenderer.GetComponent<CustomSprite>();
                if (_oldCustomSprite != null)
                {
                    Sprite = _oldCustomSprite.Sprite;
                }
                else
                {
                    _oldUnitySprite = GameSpriteRenderer.GetComponent<SpriteRenderer>();
                    if (_oldUnitySprite != null)
                        Sprite = _oldUnitySprite.sprite;
                }

                Material.EnableKeyword("NORMAL_TEXCOORD");
            }

            if (_oldSecondaryColor != AdditiveColor || forceUpdate)
            {
                UpdateSecondaryColor();
                _isMeshDirty = true;
                _oldSecondaryColor = AdditiveColor;
            }

            base.UpdateMeshData(forceUpdate);
        }
开发者ID:Elendow,项目名称:GGJ2016,代码行数:35,代码来源:LightObstacleSprite.cs


示例18: ExportToString

		public static string ExportToString (Mesh mesh, Renderer renderer, bool uselhcoords = true, bool separateSubmeshes = true){
			Material[] mats = renderer.sharedMaterials;
			// Initiation
			StringBuilder sb = new StringBuilder();
			//Header
			sb.Append("o ").Append("Plane").Append("\n");
			foreach(Vector3 v in mesh.vertices) {
				sb.Append(string.Format("v {0:0.000000} {1:0.000000} {2:0.000000}\n",(uselhcoords?-v.x:v.x),v.y,v.z));
			}
			sb.Append("\n");
			foreach(Vector3 v in mesh.normals) {
				sb.Append(string.Format("vn {0:0.000000} {1:0.000000} {2:0.000000}\n",v.x,v.y,v.z));
			}
			sb.Append("\n");
			foreach(Vector3 v in mesh.uv) {
				sb.Append(string.Format("vt {0:0.000000} {1:0.000000}\n",v.x,v.y));
			}
			for (int material=0; material < mesh.subMeshCount; material ++) {
				sb.Append("\n");
				if (separateSubmeshes){
					sb.Append("g ").Append(mats[material].name).Append("\n");
				}
				sb.Append("usemtl ").Append(mats[material].name).Append("\n");
				sb.Append("usemap ").Append(mats[material].name).Append("\n");
				
				int[] triangles = mesh.GetTriangles(material);
				for (int i=0;i<triangles.Length;i+=3) {
					sb.Append(string.Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", 
					                        triangles[(uselhcoords?i+1:i)]+1, triangles[(uselhcoords?i:i+1)]+1, triangles[i+2]+1));
				}
			}
			return sb.ToString();
		}
开发者ID:anteaterho,项目名称:SpoutTestTemp,代码行数:33,代码来源:ObjTools.cs


示例19: Start

		void Start(){
			if(cursorIndicatorMode!=_CursorIndicatorMode.None){
				if(indicatorBuildPoint!=null){
					indicatorBuildPoint=(GameObject)Instantiate(indicatorBuildPoint);
					indicatorBuildPoint.transform.localScale=new Vector3(gridSize, 1, gridSize);
					indicatorBuildPoint.transform.parent=transform;
					indicatorBuildPoint.SetActive(false);
					indicatorCursor.name="TileIndicator_BuildPoint";
					
					foreach(Transform child in indicatorBuildPoint.transform) 
						indicatorBuildPointRen=child.GetComponent<Renderer>();
				}
				
				if(indicatorCursor!=null){
					indicatorCursor=(GameObject)Instantiate(indicatorCursor);
					indicatorCursor.transform.localScale=new Vector3(gridSize, 1, gridSize);
					indicatorCursor.transform.parent=transform;
					indicatorCursor.SetActive(false);
					indicatorCursor.name="TileIndicator_Cursor";
					
					foreach(Transform child in indicatorCursor.transform) 
						indicatorCursorRen=child.GetComponent<Renderer>();
				}
			}
			
			InitiateSampleTowerList();
		}
开发者ID:jrobison93,项目名称:Museum-of-Aviation-Exhibit,代码行数:27,代码来源:BuildManager.cs


示例20: OnAssignMaterialModel

		public void OnAssignMaterialModel (Material material, Renderer renderer) {
			if (importer == null) return;
			importer.assetPostprocessor = this;
			importer.assetImporter = this.assetImporter;
			importer.assetPath = this.assetPath;
			importer.AssetGraphOnAssignMaterialModel(material, renderer);
		}
开发者ID:ChelseaLing,项目名称:AssetGraph,代码行数:7,代码来源:InternalImporter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.Rigidbody类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.RenderTexture类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap