我在一个Scene里创建了多个ngui做的界面,做成了prefab,用的时候通过销毁和创建实现界面切换,但是每个界面只有首次进入的时候是正确的,destroy后再创建,脚本就必会报错:
The object of type 'UISprite' has been destroyed but you are still trying to access it.Your script should either check if it is null or you should not destroy the object.
经过测试,发现销毁后,再创建的物件上,不能使用 gameobject.GetComponent<UISprite>();来获取组件,否则必报上面的错误,不知道哪位大哥大姐遇到过类似的问题,想求个解决方案,实在不行解释下原因也好。多谢,多谢!!