public static void UpdateGameValueSettings() { if (File.Exists(Application.persistentDataPath + "/savedGames.gd")) { BinaryFormatter formatter = new BinaryFormatter(); FileStream fs = File.Open(Application.persistentDataPath + "/savedGames.gd", FileMode.Open); try { save = (ClassSave)formatter.Deserialize(fs); Debug.Log("Updated version"); } catch (Exception ex) { Debug.Log(ex.Message); fs.Position = 0; var save1 = (ClassSaveOld)formatter.Deserialize(fs); save = new ClassSave(0.5f, 0.5f, save1.nickName); save.id = save1.id; save.idSceneLastOpen = save1.idSceneLastOpen; Save(); Debug.Log("Update settings properties"); } fs.Close(); } }
public static void Load() { if (File.Exists(Application.persistentDataPath + "/savedGames.gd")) { BinaryFormatter bf = new BinaryFormatter(); FileStream fs = File.Open(Application.persistentDataPath + "/savedGames.gd", FileMode.Open); save = (ClassSave)bf.Deserialize(fs); fs.Close(); } else { Save(); } }
static void SaveData() { ItemData2 item = new ItemData2(); item.id = 4; item.name = "dfg"; item.isStackable = true; ItemData item0 = new ItemData(); item0.id = item.id; item0.isStackable = item.isStackable; item0.name = item.name; Quest quest = new Quest(); quest.id = 0; quest.name = "45fgh"; ClassSave Save1 = new ClassSave(); Save1.ListItem = new List <ItemData>(); Save1.ListItem.Add(item0); Save1.ListQuest = new List <Quest>(); Save1.ListQuest.Add(quest); Save1.ListInt = new List <int>(); Save1.ListInt.Add(4); Save1.ListInt.Add(2); Save1.ListInt.Add(5); Save1.ListInt.Add(6); Save1.id = 0; Save1.bool1 = true; Save1.stroka = "Привет. Как дела?"; if (!Directory.Exists(Directory.GetCurrentDirectory() + "/saves")) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/saves"); } FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "/saves/save1.art", FileMode.Create); BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(fs, Save1); fs.Close(); }
public static void Save() { if (save != null) { Debug.Log("SAVE " + Application.persistentDataPath + "/savedGames.gd"); BinaryFormatter bf = new BinaryFormatter(); FileStream fs = File.Create(Application.persistentDataPath + "/savedGames.gd"); bf.Serialize(fs, save); fs.Close(); } else { save = new ClassSave(); if (save.id == -1) { UI_Raiting.GetID(false); } Save(); } OnSaveSetting?.Invoke(); }
static void LoadData() { if (File.Exists(Directory.GetCurrentDirectory() + "/saves/save1.art")) { FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "/saves/save1.art", FileMode.Open); BinaryFormatter bformatter = new BinaryFormatter(); try { ClassSave Load1 = (ClassSave)bformatter.Deserialize(fs); Console.Write(Load1.stroka + Load1.ListInt[3]); Console.Write(Load1.ListItem[0].id + Load1.ListItem[0].name + Load1.ListItem[0].isStackable); Console.Write(Load1.ListQuest[0].id + Load1.ListQuest[0].name); } catch (System.Exception e) { Console.Write("Error=("); } finally { fs.Close(); } } }
private void btnSave_Click(object sender, EventArgs e) { VC.CopyToClipBorad(); ClassSave.Save(VC.getCaptureImage()); }
void Awake() { save = GameObject.Find("SaveButton"); spend = save.GetComponent <ClassSave> (); }
void Awake() { batn = GameObject.FindGameObjectWithTag("Sejvanje"); klasaBR = batn.GetComponent <ClassSave> (); }