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());
}


  1. Leave a comment

Leave a comment