为了账号安全,请及时绑定邮箱和手机立即绑定

隐藏的跟输出的名字都不是一个

在play脚本里

void Start ()

{

//获取第一个方块并隐藏

Debug.Log (list_[5].name);

list_ [5].gameObject.SetActive (false);

}

上面输出的是正确的名字,但是后边隐藏的都是最后一个,就是第28个,为什么,为什么,为什么,跟老师的代码都对了 一样的,有知道的同学给说一下,谢谢,谢谢,谢谢

正在回答

1 回答

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);
				}
		}

}

你再试试

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
《小十传奇》 Unity3D 休闲游戏开发
  • 参与学习       40232    人
  • 解答问题       123    个

手把手教你用Unity3D开发休闲游戏,小伙伴们,还等什么

进入课程

隐藏的跟输出的名字都不是一个

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信