这里是我的代码:比较游戏物体的名称,其母公司的名称
GameObject no=GameObject.Find("LevelButton");
GameObject noparent=GameObject.Find("LevelPHwithrect (" + (i + 1) + ")");
的问题是,我能够找到gameobjects
,但是当我打电话
if(no.transform.parent.name==noparent.transform.name)
{
//do something
}
我得到一个错误说空引用,即使它发现的对象,我已经设置no的父母noparent。
请原谅我,如果在这篇文章中有错误,因为这是我的第一天堆栈溢出。
下次会记住 –