隱藏的跟輸出的名字都不是一個
在play腳本里
void Start ()
{
//獲取第一個方塊并隱藏
Debug.Log (list_[5].name);
list_ [5].gameObject.SetActive (false);
}
上面輸出的是正確的名字,但是后邊隱藏的都是最后一個,就是第28個,為什么,為什么,為什么,跟老師的代碼都對了 一樣的,有知道的同學給說一下,謝謝,謝謝,謝謝
在play腳本里
void Start ()
{
//獲取第一個方塊并隱藏
Debug.Log (list_[5].name);
list_ [5].gameObject.SetActive (false);
}
上面輸出的是正確的名字,但是后邊隱藏的都是最后一個,就是第28個,為什么,為什么,為什么,跟老師的代碼都對了 一樣的,有知道的同學給說一下,謝謝,謝謝,謝謝
2016-05-29
舉報
2016-07-10
using?UnityEngine; using?System.Collections; public?class?Play?:?MonoBehaviour?{ public?Square?getSquare(int?x,?int?y){ int?n?=?x?*?4?+?y; return?list_[n]; } private?Square[]?list_?=?null; void?Awake(){ list_?=?this.GetComponentsInChildren<Square>?(); Debug.Log?(list_.Length); } void?Start(){ //list_?[0].gameObject.SetActive?(false); foreach(Square?square?in?list_){ square.gameObject.SetActive?(false); } } }你再試試