一:获取对象
1.通过对象名称获取:objCube=GameObject.Find("Cube");
private var objCube:GameObject;
private var isCubeRoate=false;
function Start () {
objCube=GameObject.Find("Cube");
}
function Update(){
if(isCubeRoate){
objCube.transform.Rotate(0.0f,Time.deltaTime*200,0.0f);
}
}
function OnGUI(){
if(GUILayout.Button("旋转",GUILayout.Height(50))){
isCubeRoate=true;
}
}
2.通过tag标签获取单个游戏对象:objCube=GameObject.FindWithTag("Finish");
3.通过游戏标签获取多组游戏对象:objCube=GameObject.FindGameObjectsWithTag("Finish");
二:子对象
Unity3D如何获取对象和子对象,布布扣,bubuko.com
原文:http://www.cnblogs.com/tonge/p/3605624.html