一:访问组件
1:系统自带的组件
大多数都可以转行成所在类的成员变量,通过成员变量的访问
transform.Rotate(0,speed*Time.deltaTime,0);
2:如果是自己定义的组件,比如脚本
需要类中定义一个变量,并获取该组件的引用,从而使用这个组件
float speed = 5;
turnround2 other;
// Use this for initialization
void Start () {
other = GetComponent<turnround2>();
Debug.Log(turnround2.other.);
}
二:访问游戏物体
在Unity脚本中,开发人员可以通过下面量的方式来访问游戏对象。