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

            worldSaveData.savedGameObjects.Add(saveData);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }