void Start () {
List<GameObject> boxes = new List<GameObject>();
}
void FixedUpdate()
{
if (boxes.Count < 5)
{
GameObject box = Instantiate(gameObject, position, Quaternion.identity);
boxes.Add(box);
}
}
这段代码的意图是想克隆几个游戏对象,但是一运行就会克隆无数个对象,结果Unity崩了。请问这是什么原因呢?感觉boxes.Count一直都小于5。。。