unity3d - Serialization error: Error when trying to link to a previously seen object -


my game has 2 scenes: scene main menu, , scene actual game. if playing in game scene, able return main menu. code brings me main menu looks this:

application.loadlevel(“menu”); 

if click on new game in main menu, game scene restarts, i.e. following code executed:

application.loadlevel(“game”); 

when scene loads following error reported:

missingreferenceexception: object of type ‘storeinformation’ has been destroyed still trying access it. script should either check if null or should not destroy object. uniqueidentifier.configureid () (at assets/plugins/whydoidoit.com/serialization/uniqueidentifier.cs:107) uniqueidentifier.fullconfigure () (at assets/plugins/whydoidoit.com/serialization/uniqueidentifier.cs:86) uniqueidentifier.<awake>m__43 () (at assets/plugins/whydoidoit.com/serialization/uniqueidentifier.cs:101) savegamemanager.awake () (at assets/plugins/whydoidoit.com/serialization/savegamemanager.cs:295) 

note: realised don’t have start game in scene “game” error occur. if start game @ main menu, i.e. scene “menu”, , go scene “game” using application.loadlevel(“game”), error occurs.

i used pause menu save game,on save snippet used :

if(guilayout.button("save game"))  {   levelserializer.savegame(gamename);  application.loadlevel("menu");      } 

and on load button used

for(var sg in levelserializer.savedgames[levelserializer.playername])  {  if(guilayout.button(sg.caption)) {  levelserializer.loadnow(sg.data);  time.timescale = 1;  }  application.loadlevel("game"); 

to return gamelevel resume game. code working correctly if remain on same page,but moving gamelevel menu page returns me above error. doing wrong??please me sort out.

the variable storeinformation null. because didn't set in inspector or because gameobject holds deleted on scene load.

if later need call dontdestroyonload keep gameobject being deleted


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -