public static void SaveChanges(Params parameters) { #if UNITY_STANDALONE || UNITY_EDITOR SaveGlobal data = _dataInterface.LoadData($"{Application.dataPath}/Save/GlobalData.arcueid"); #else SaveGlobal data = _dataInterface.LoadData($"{Application.persistentDataPath}/GlobalData.arcueid"); #endif for (int i = 0; i < data.intData.Count; i++) { data.intData[i] = parameters.intData[i].Value; } for (int i = 0; i < data.floatData.Count; i++) { data.floatData[i] = parameters.floatData[i].Value; } for (int i = 0; i < data.boolData.Count; i++) { data.boolData[i] = parameters.boolData[i].Value; } for (int i = 0; i < data.stringData.Count; i++) { data.stringData[i] = parameters.stringData[i].Value; } #if UNITY_STANDALONE || UNITY_EDITOR data.SaveData($"{Application.dataPath}/Save/GlobalData.arcueid", true); #else data.SaveData($"{Application.persistentDataPath}/GlobalData.arcueid", true); #endif }
private static void CreateData(Params parameters, string path) { SaveGlobal data = new SaveGlobal() { intData = new List <int>(), floatData = new List <float>(), boolData = new List <bool>(), stringData = new List <string>() }; for (int i = 0; i < parameters.intData.Count; i++) { data.intData.Add(parameters.intData[i].Value); } for (int i = 0; i < parameters.floatData.Count; i++) { data.floatData.Add(parameters.floatData[i].Value); } for (int i = 0; i < parameters.boolData.Count; i++) { data.boolData.Add(parameters.boolData[i].Value); } for (int i = 0; i < parameters.stringData.Count; i++) { data.stringData.Add(parameters.stringData[i].Value); } data.SaveData(path, true); }
public static void SaveSettings(SaveGlobal data) { #if UNITY_STANDALONE || UNITY_EDITOR data.SaveData($"{Application.dataPath}/Save/Settings.arcueid", true); #else data.SaveData($"{Application.persistentDataPath}/Settings.arcueid", true); #endif }
public static void LoadChanges(Params parameters) { string path; #if UNITY_STANDALONE || UNITY_EDITOR path = Application.dataPath; #else path = $"{Application.persistentDataPath}/GlobalData.arcueid"; #endif #if UNITY_STANDALONE || UNITY_EDITOR if (!ParadoxSerialization.CheckFolder($"{path}/Save")) { ParadoxSerialization.CreateFolder(path, "Save"); CreateData(parameters, $"{path}/Save/GlobalData.arcueid"); return; } if (!ParadoxSerialization.CheckFile($"{path}/Save/GlobalData.arcueid")) { CreateData(parameters, $"{path}/Save/GlobalData.arcueid"); return; } #else if (!ParadoxSerialization.CheckFile(path)) { CreateData(parameters, path); return; } #endif #if UNITY_STANDALONE || UNITY_EDITOR SaveGlobal data = _dataInterface.LoadData($"{path}/Save/GlobalData.arcueid"); #else SaveGlobal data = _dataInterface.LoadData(path); #endif for (int i = 0; i < data.intData.Count; i++) { parameters.intData[i].Value = data.intData[i]; } for (int i = 0; i < data.floatData.Count; i++) { parameters.floatData[i].Value = data.floatData[i]; } for (int i = 0; i < data.boolData.Count; i++) { parameters.boolData[i].Value = data.boolData[i]; } for (int i = 0; i < data.stringData.Count; i++) { parameters.stringData[i].Value = data.stringData[i]; } }
public SaveGlobal(int level, float curr_rating) { threshold[0] = 3f; threshold[1] = 3f; threshold[2] = 3f; threshold[3] = 3f; threshold[4] = 3f; SaveGlobal data = SaveSystem <SaveGlobal> .LoadPlayer("global"); rating[level - 1] = Mathf.Max(data.rating[level - 1], curr_rating); if (curr_rating >= threshold[level - 1]) { farthest_level = Mathf.Max(data.farthest_level, level); } }
public void SaveGlobalData() { if (!Directory.Exists(Application.persistentDataPath + "/SaveSlot")) { Directory.CreateDirectory(Application.persistentDataPath + "/SaveSlot"); } BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/SaveSlot/GlobalData.save"; FileStream stream = new FileStream(path, FileMode.Create); SaveGlobal data = new SaveGlobal(playerGO.transform.position, world.offsetX, world.offsetZ); formatter.Serialize(stream, data); stream.Close(); }
public SaveGlobal LoadGlobalData() { string path = Application.persistentDataPath + "/SaveSlot/GlobalData.save"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); SaveGlobal data = formatter.Deserialize(stream) as SaveGlobal; stream.Close(); return(data); } else { return(null); } }
private void Start() { int xLevels = Mathf.RoundToInt(viewPortWidth / reservedWidth); int yLevels = Mathf.RoundToInt(viewPortHeight / reservedHeight); SaveGlobal data = SaveSystem <SaveGlobal> .LoadPlayer("global1"); if (data == null) { data = new SaveGlobal(1, 0f, 1, 0f); SaveSystem <SaveGlobal> .SavePlayer(data, "global1"); } else { Debug.Log(data.farthest_level); } for (int i = 0; i < maxLevel; i++) { GameObject levelCard = Instantiate(levelPrefab, canvas.transform); int levelNumber = i + 1; levelCard.GetComponent <RectTransform>().anchoredPosition = new Vector2(verticalHorizontalGap + reservedWidth * (i % xLevels), -(400 + verticalHorizontalGap + reservedHeight * (i / xLevels))); if (data.farthest_level >= levelNumber) { levelCard.transform.Find("Lock").gameObject.SetActive(false); levelCard.transform.Find("rating").GetComponent <Text>().text = "Rating: " + data.rating[levelNumber - 1].ToString("0.00"); //activate level //break; } else { levelCard.transform.Find("Lock").gameObject.SetActive(false); //levelCard.GetComponent<Button>().interactable = false; //lock //break; } // data.close(); levelCard.GetComponent <Button>().onClick.AddListener(() => startLevel(levelNumber)); levelCard.transform.GetChild(0).gameObject.GetComponent <Text>().text = levelNumber.ToString(); } //startLevel(1); }
public static void LoadSettings(System.Action <SaveGlobal> OnComplete, SettingsManager manager) { string path; #if UNITY_STANDALONE || UNITY_EDITOR path = Application.dataPath; #else path = $"{Application.persistentDataPath}/Settings.arcueid"; #endif #if UNITY_STANDALONE || UNITY_EDITOR if (!ParadoxSerialization.CheckFolder($"{path}/Save")) { ParadoxSerialization.CreateFolder(path, "Save"); manager.GetData().SaveData($"{path}/Save/Settings.arcueid", true); return; } if (!ParadoxSerialization.CheckFile($"{path}/Save/Settings.arcueid")) { manager.GetData().SaveData($"{path}/Save/Settings.arcueid", true); return; } #else if (!ParadoxSerialization.CheckFile(path)) { manager.GetData().SaveData($"{path}/Save/Settings.arcueid", true); return; } #endif #if UNITY_STANDALONE || UNITY_EDITOR SaveGlobal data = _dataInterface.LoadData($"{path}/Save/Settings.arcueid"); #else SaveGlobal data = _dataInterface.LoadData(path); #endif OnComplete(data); }
public SaveGlobal GetData() { SaveGlobal data = new SaveGlobal() { boolData = new List <bool>(), intData = new List <int>(), floatData = new List <float>(), stringData = new List <string>() }; for (int i = 0; i < _dropdownsData.Count; i++) { data.intData.Add(_dropdownsData[i].GetDropdownValue()); } if (_resolution == null) { _resolution = GameObject.FindObjectOfType <ResolutionDropdownSetter>(); } if (_quality == null) { _quality = GameObject.FindObjectOfType <QualityDropdownSetter>(); } data.intData.Add(_resolution.GetResolution()); data.intData.Add(_quality.GetQuality()); for (int i = 0; i < _toggles.Count; i++) { data.boolData.Add(_toggles[i]); } data.boolData.Add(_fullScreen.GetFullscreen()); for (int i = 0; i < _slidersData.Count; i++) { data.floatData.Add(_slidersData[i].GetVolume()); } return(data); }
void CheckData() { if (saver.isFileExists() == true) { Debug.Log("1"); SaveGlobal global = saver.LoadGlobalData(); offsetX = global.offsetX; offsetZ = global.offsetZ; player = Instantiate(playerGO, new Vector3(global.position[0], global.position[1], global.position[2]), Quaternion.identity); modify.playerGO = player; saver.playerGO = player; for (int x = 0; x < chunks.GetLength(0); x++) { for (int z = 0; z < chunks.GetLength(2); z++) { SaveChunk chunk = saver.LoadChunkData(x, z); if (chunk != null) { SaveBytesToData(chunk); SaveChunkToArray(chunk.chunkIdX, chunk.chunkIdZ); } } } } else { Debug.Log("2"); player = Instantiate(playerGO, new Vector3(worldX / 2f, 50f, worldZ / 2f), Quaternion.identity); modify.playerGO = player; saver.playerGO = player; offsetX = Random.Range(0, 999999); offsetZ = Random.Range(0, 999999); } }