/// <summary> /// Use awake function to initialize our game save and load. /// </summary> void Awake() { Saver.OnSaved += Saver_OnSaved; Saver.OnLoaded += Saver_OnLoaded; // Initialize our game data demoData = new DemoData(); // Initialize the Saver with the default configurations Saver.Initialize(FormatType.JSON); // Load game data after initialization demoData = Saver.Load <DemoData> (fileName); }
void OnGUI() { GUILayout.Label("This will get saved automatically when you change or input."); if (GUILayout.Button(string.Format("Click Count: {0}", demoData.clickCount))) { demoData.clickCount++; } demoData.yourName = GUILayout.TextField(demoData.yourName); if (GUILayout.Button("Save")) { // Save the game data Saver.Save(demoData, fileName); } if (GUILayout.Button("Load")) { // Load the game data demoData = Saver.Load <DemoData> (fileName); } }