Facebook Twitter Gplus LinkedIn RSS

Examples

I will use this page to provide simple examples of using serialization.

iPhone/iPad save on pause

When an iPad or an iPhone is suspended due to the user pressing the home button or otherwise selecting another application – your app can be terminated before it ever runs again.  Therefore it makes sense to save the status of your game when the pause happens.

That is easy to enable with Unity Serializer.


static var loaded = false;
static function Initialize() {

  if(!loaded) {
    loaded = true;
    var levelData = PlayerPrefs.GetString("_PAUSE_GAME_","");
    if(!string.IsNullOrEmpty(levelData))
        LevelSerializer.LoadSavedLevel(levelData);
   }
}

function Start() {
    Initialize();
}

function OnApplicationPause(paused : boolean) {
    if(paused) PlayerPrefs.SetString("_PAUSE_GAME_", LevelSerializer.SerializeLevel());
}


Home Forums Unity Serializer Examples

This topic contains 0 replies, has 1 voice, and was last updated by  whydoidoit 7 months, 2 weeks ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1331

    whydoidoit
    Keymaster

    I will use this page to provide simple examples of using serialization. iPhone/iPad save on pause When an iPad or an iPhone is suspended due to the us
    [See the full post at: Examples]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.