예제 #1
0
        public override void Save(WorldSaveData worldSaveData)
        {
            base.Save(worldSaveData);
            GameObjectSaveData saveData = new GameObjectSaveData(posterInitData, transformData);

            worldSaveData.savedGameObjects.Add(saveData);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }