. My game has two scenes: a scene for the main menu, and a scene for the actual game. If I am playing in the game scene, I am able to return to the main menu. The code that brings me to the main menu looks like this:
Application.LoadLevel(“Menu”);
If I click on new game in the main menu, the game scene restarts, i.e. the following code is executed:
Application.LoadLevel(“Game”);
When the scene loads the following error is reported:
MissingReferenceException: The object of type ‘StoreInformation’ 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.
UniqueIdentifier.ConfigureId () (at Assets/Plugins/whydoidoit.com/Serialization/UniqueIdentifier.cs:107)
UniqueIdentifier.FullConfigure () (at Assets/Plugins/whydoidoit.com/Serialization/UniqueIdentifier.cs:86)
UniqueIdentifier.m__43 () (at Assets/Plugins/whydoidoit.com/Serialization/UniqueIdentifier.cs:101)
SaveGameManager.Awake () (at Assets/Plugins/whydoidoit.com/Serialization/SaveGameManager.cs:295)
Note: I just realised I don’t have to start the game in scene “Game” for the error to occur. If I start the game at the main menu, i.e. scene “Menu”, and then go to scene “Game” using Application.LoadLevel(“Game”), the error occurs.
i used the pause menu to save the game,on save snippet used :
>
if(GUILayout.Button("Save Game"))
{
LevelSerializer.SaveGame(gameName);
Application.LoadLevel("Menu");
}
and on load button i 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 back to gamelevel to resume the game.
This code is working correctly if i remain on same page,but from moving back to gamelevel it gives me the above error.
what am i doing wrong??please help me to sort it out.
↧