Exemple #1
0
        // save the fields
        public SceneSaveData SaveGeneralInfo(List <HeroKitObject> heroKitObjects, bool savePersistentObjects)
        {
            SceneSaveData saveData = new SceneSaveData();

            // Scene
            saveData.sceneName = (savePersistentObjects) ? "PersistentObjects" : UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;

            // Here objects in scene
            List <HeroSaveData> heroList = new List <HeroSaveData>();

            // save hero data
            for (int i = 0; i < heroKitObjects.Count; i++)
            {
                if (heroKitObjects[i] != null && heroKitObjects[i].heroObject != null && heroKitObjects[i].persist == savePersistentObjects)
                {
                    // only save objects that are flagged to be saved
                    if (!heroKitObjects[i].doNotSave)
                    {
                        HeroSaveData saveHeroData = new HeroSaveData();
                        saveHeroData = SaveHeroObject(saveHeroData, heroKitObjects[i]);
                        heroList.Add(saveHeroData);
                    }
                }
            }

            saveData.heroObjects = heroList.ToArray();

            return(saveData);
        }
Exemple #2
0
        // Get the scene data that you want to save
        private string GetSceneData(HeroKitObject hko, bool savePersistentObjects)
        {
            // filter the hero kit objects in the scene
            int objectCount = 9999999;
            List <HeroKitObject> heroKitObjects = HeroActionCommonRuntime.GetHeroObjects(HeroActionCommonRuntime.GetHeroObjectsInScene(), objectCount);

            // get info to save
            string jsonText = "";

            // save general game info
            SceneSaveData saveData = SaveGeneralInfo(heroKitObjects, savePersistentObjects);

            jsonText += JsonUtility.ToJson(saveData);

            //Debug.Log(jsonText);

            return(jsonText);
        }