腳本中 Find 按名字尋找物體

using UnityEngine;
using System.Collections;

public class test2 : MonoBehaviour {
	GameObject obj;
	// Use this for initialization
	void Start () {
<span style="white-space:pre">	</span>  <span style="background-color: rgb(102, 102, 204);">  //<span style="font-family: Arial, Helvetica, sans-serif;">GameObject.Find用於尋找名字爲"Cube"的與腳本所依附的物體的同級物體</span></span>
	    obj = GameObject.Find ("Cube");
	}
	
	// Update is called once per frame
	void Update () {
	//	obj.GetComponent<Transform> ().Rotate (0, 0, 5);
<span style="white-space:pre">		</span><span style="background-color: rgb(102, 102, 204);">//<span style="font-family: Arial, Helvetica, sans-serif;">transform.Find ("Cube")用於尋找名字爲"Cube"的子物體;</span></span>
		transform.Find ("Cube").transform.Rotate (0, 5, 0);
	}
}

發佈了26 篇原創文章 · 獲贊 27 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章