Unity3d OnDisable()
问题:.cs脚本当“跳转场景”,OnDisable() 中UISprite.enable=false时报 MissingReferenceException
MissingReferenceException: 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.
跳转场景,Unity3d销毁顺序:GameObject->.cs;所以在OnDisable()时,只保留了UISprite索引,可UISprite已经被销毁。只需加个前提条件:if(UISprite!=null);