Unity3d--GetComponent的使用方法
2016-04-10 20:28
537 查看
Unity3d--GetComponent的使用方法
using UnityEngine; using System.Collections; public class Test : MonoBehaviour { private Quaternion[] quaters; private Color[] colors; private Material mr; void Awake(){ quaters = new Quaternion[7]; colors = new Color[7]; } void Start () { int i = 0; while (i<quaters.Length) { quaters [i] = Random.rotationUniform; colors[i] = new Color (Random.value, Random.value, Random.value); Transform child = this.transform.GetChild (i); child.rotation = quaters [i]; //获取物体组件,修改组件参数值。 child.GetComponent<MeshRenderer> ().material.color = colors [i]; i++; } } }
相关文章推荐
- Unity 设置Android SDK path
- 关于Unity的几种XML读取方式
- Unity3d--随机数Random.rotation
- Unity3d--timeScale的使用方法
- Unity Shader 一 激光特效Shader
- Unity的UI文档
- Unity3d之手机代码跟新策略探讨
- Unity3d之手游资源热跟新资源探讨
- Unity3d之资源打包Assetbundle
- Unity3D学习笔记(一)接入百度移动广告(Android详细讲解)
- Unity3d之角色控制器
- Unity UGUI图文混排源码(二)
- Unity UGUI图文混排源码(二)
- Unity UGUI图文混排源码(一)
- Unity UGUI图文混排源码(一)
- Unity中Microphone类进行录音保存
- Unity光照图UV显示
- 【Unity】4.4 添加角色控制器
- 【Unity】4.3 地形编辑器
- A* Pathfinding Project (Unity A*寻路插件) 使用教程