public static void SaveWorld(MasterWorldSave masterWorldSave) { PersistentData.Instance.CurrentWorld = masterWorldSave; string worldPath = Application.persistentDataPath + "/Worlds/" + masterWorldSave.guid + ".data"; File.WriteAllBytes(worldPath, Encoding.Default.GetBytes(JsonConvert.SerializeObject(masterWorldSave))); Debug.Log(File.ReadAllText(worldPath)); PersistentData.Instance.CurrentWorld = masterWorldSave; }
void LoadDDL() { string[] saves = LoadHelper.GetWorldSaves(); for (int i = 0; i < saves.Length; i++) { masterWorldSave = LoadHelper.GetMasterWorldSave(saves[i]); Debug.Log(saves[i]); GenerateWorldSlot(masterWorldSave.name, 0f, i + 1); } Instantiate(Resources.Load <GameObject>("Prefabs/NewWorldSlot"), content.transform); }
void checkToggle(bool o) { if (toggle.isOn) { int slotNum = Int32.Parse(this.gameObject.transform.Find("SlotNumBackground").transform.Find("SlotNum").GetComponent <Text>().text) - 1; MasterWorldSave s = LoadHelper.GetMasterWorldSave(Directory.GetFiles(Application.persistentDataPath + "/Worlds/")[slotNum]); PersistentData.Instance.CurrentWorld = s; Debug.Log(PersistentData.Instance.CurrentWorld.name); } }
// Start is called before the first frame update void Start() { saveObject = new SaveObject(); masterSave = new MasterSave(); masterWorldSave = new MasterWorldSave(); characterInventory = new CharacterInventory(); characterPath = Application.persistentDataPath + "/Characters/"; if (!Directory.Exists(Application.persistentDataPath + "/Characters/")) { Directory.CreateDirectory(Application.persistentDataPath + "/Characters/"); } if (!Directory.Exists(Application.persistentDataPath + "/Worlds/")) { Directory.CreateDirectory(Application.persistentDataPath + "/Worlds/"); } }