public override void Save(WorldSaveData worldSaveData) { base.Save(worldSaveData); GameObjectSaveData saveData = new GameObjectSaveData(posterInitData, transformData); worldSaveData.savedGameObjects.Add(saveData); }
public virtual void Save(WorldSaveData worldSaveData) { // This would occur if we place objects in the Editor manually. if (initData == null) { initData = AttemptRecreateInitData(); } // Record current transform in serializable format transformData = new SerializableTransform(this.transform); }
public void Save() { /////////////////////// // Save current changes /////////////////////// Debug.Log("Saving"); worldSaveData = new WorldSaveData(); // SaveLoadableObjects will register themselves with WorldSaveData cbSave(worldSaveData); string worldSaveDataJson = JsonUtility.ToJson(worldSaveData); PlayerPrefs.SetString("SaveData", worldSaveDataJson); }
public void Load() { /////////////////////// // Clear existing world /////////////////////// ClearWorld(); /////////////////////// // Load saved world /////////////////////// Debug.Log("Loading"); WorldSaveData loadData = (WorldSaveData)JsonUtility.FromJson(PlayerPrefs.GetString("SaveData"), typeof(WorldSaveData)); // SpawnHandler takes care of instantiation, initialization and placement of all saved objects spawnHandler.SpawnAllFromSaveData(loadData.savedGameObjects); }