Array not saving/restoring

Array not saving/restoring

Postby sharmoni » Sat Sep 11, 2010 11:08 pm

I've got a 1D array of integers that saves and auto-restores fine in the editor, but doesn't function in my iPad build. I think it is at least storing, because on restart the program locks up at the point where it is loading the save data.
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: Array not saving/restoring

Postby Brady » Sun Sep 12, 2010 4:05 am

Do you have any output in the xCode debug console?
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: Array not saving/restoring

Postby sharmoni » Sun Sep 12, 2010 4:45 am

I ran another build and realized it is not locking any of the code, but my program is unable to proceed until it gets the stored array. So it's finding an existing savegame from the auto-restore, but it can't load the data from the array and never gets past that point.
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: Array not saving/restoring

Postby sharmoni » Sun Sep 12, 2010 10:28 pm

I restructured my code to not use an array, and then when I had problems with a saved GameObject I simplified it to just saved strings and integers. It still won't run on the iPad. The program doesn't crash, it just stops my initialization script when it tries to make any gameSaveMaster call.

I'm using EZ GUI 1.05_b3 and EZ Game Saver 1.32_b1.
I'm building with XCode Version 3.2.3 using the iPhone Device 3.2 setting to an iPad running 3.2.2.
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: Array not saving/restoring

Postby Brady » Mon Sep 13, 2010 6:06 am

Try clearing any stored savegames incase there's some save data that's holding up your scripts somehow, and then start with fresh save data. You'll need to do this anytime you change what is being saved as altering what gets saved invalidates any previous save data. The way to clear saves is to call SaveGameMaster.DeleteProfile("profile name") as well as SaveGameMaster.ClearGlobalTierKeys().
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: Array not saving/restoring

Postby sharmoni » Mon Sep 13, 2010 2:20 pm

I already had SaveGameMaster.DeleteProfile in my reset button to clear the data in game. I've added saveGameMaster.ClearGlobalTierKeys(), but I'm not seeing a difference. I've been completely deleting the game from the iPad to clear the data each time I install a new build.

In the following code it gets as far as the commented out line (that's the one that freezes the script). The string var restoreSave is the only profile I have.
Code: Select all
   if (saveGameMaster.SaveGameExists(restoreSave, 0)) {
//      saveGameMaster.Load(restoreSave, 0);
//      restored = true;
   } else {
      saveGameMaster.CreateProfile(restoreSave);
      restored = false;
   }


My reset code works fine.
Code: Select all
function ResetGame() {
   saveGameMaster.DeleteProfile(gameAI.restoreSave);
   saveGameMaster.ClearGlobalTierKeys();
   saveGameMaster.CreateProfile(gameAI.restoreSave);
   inputControl.NewGame();
}
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: Array not saving/restoring

Postby Brady » Mon Sep 13, 2010 9:00 pm

Hmmm... it is strange that you're not getting anything in the XCode console. That would be very helpful in discovering what is going on, since a LOT of stuff happens after Load() is called. When you build to the device, make sure to have "Strip Debugging Symbols" unchecked in the build settings, and that the "Script Call Optimization" is set to "Slow and Safe" in the player settings. This should allow whatever is causing the exception to get caught and display in the XCode debug console.

If that doesn't work, could you e-mail me privately with a sample package I could test on my end to see what's happening? Thanks!
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: Array not saving/restoring

Postby sharmoni » Tue Sep 14, 2010 12:48 am

Ok, now I've learned something new. I never used the console before. That's an extremely useful tool! I wish I had learned about that two years ago when I started teaching myself how to program for the iPhone.

Here's what seems to be the relevant part from the first build and run:
Code: Select all
End Load File completely 1808.748000

create profile (Filename: /Users/build/builds/unity-iphone/iphone/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1719)
 -> force accelerometer registration
-> applicationDidBecomeActive()
-> applicationWillTerminate()
ExecutionEngineException: Attempting to JIT compile method 'System.Reflection.MonoProperty:GetterAdapterFrame<UIButton, bool> (System.Reflection.MonoProperty/Getter`2<UIButton, bool>,object)' while running with --aot-only.


System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000]
GameDataSaver.Save (System.String saveName, Int32 saveNum, System.String objID)
SaveGameManager.Save (System.String profile, Int32 saveNum)
SaveGameMaster.Save (System.String profile, Int32 saveNum, System.String saveName)
SaveGameMaster.OnApplicationQuit ()
 


Here's the same section on the second run:
Code: Select all
End Load File completely 408.315167

found restored (Filename: /Users/build/builds/unity-iphone/iphone/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1719)
UnityException: GameObject has undefined tag!
GameAI.SetupPieces ()
GameAI.Start ()
 


The "GameObject has undefined tag" error (right after my Debug.Log "found restored") is where my code stops running.
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Re: Array not saving/restoring

Postby Brady » Tue Sep 14, 2010 9:18 am

Hmmm, I'm not sure why you're getting different results on a subsequent run, but the first problem is definitely the property bug in Unity's .NET 2.0/2.1 implementation. Perhaps that is somehow causing the second error? I can't say as to that one, but the first one is definitely it. For whatever it is saving here, if you can change it from a property to a regular field, then it should work. That's the weird thing - Unity's .NET 2.0/2.1 implementation works fine for fields, just not properties. It worked for both in .NET 1.1, but they broke it somehow in 2.0/2.1. They know about this, however, and are working on it.
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: Array not saving/restoring

Postby sharmoni » Tue Sep 14, 2010 2:43 pm

WooHoo! I can get it to work now. I saved all my values in my scripts rather than the properties and it's all good. Thank you Brady!
sharmoni
 
Posts: 53
Joined: Fri Jul 30, 2010 1:36 am

Next

Return to EZ Game Saver General

Who is online

Users browsing this forum: No registered users and 3 guests

cron