隐藏的跟输出的名字都不是一个
在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
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);
}
}
}你再试试
举报