Beispiel #1
0
        // Save the scene data in a temporary directory.
        public void SaveSceneData(HeroKitObject hko, bool savePersistentObjects)
        {
            // Save all herokit objects in the current scene in the database
            HeroKitDatabase.AddAllHeroKitObjects();

            // get the path where you want to put the save game file on the player's device
            string sceneName = (savePersistentObjects) ? "PersistentObjects" : UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
            string path      = Application.temporaryCachePath + "/HeroScenes/" + sceneName + ".json";

            // convert game data to json data
            string jsonText = GetSceneData(hko, savePersistentObjects);

            // save the json data to player's device
            File.WriteAllText(path, jsonText);
        }