internal static void LoadAddonSavedValues(string addonId) { // Check if values have already been loaded if (SavedValues.ContainsKey(addonId)) { return; } // Create a new entry SavedValues.Add(addonId, new Dictionary <string, List <Dictionary <string, object> > >()); // Verify that the directory exists Directory.CreateDirectory(SaveDataDirectoryPath); // Get the file path var filePath = Path.Combine(SaveDataDirectoryPath, addonId + ".json"); // Check if save file exists if (!File.Exists(filePath)) { return; } // Deserialize file contents var data = JsonConvert.DeserializeObject <Dictionary <string, List <Dictionary <string, object> > > >(File.ReadAllText(filePath)); // Apply saved data to dictionary SavedValues[addonId] = data; }
void Start() { Point = transform.localPosition; sv = FindObjectOfType<SavedValues>(); maxX = 3; minX = -3; maxY = 3f; minY = -0.5f; }
internal static void OnSaveTimerElapsed(object sender, ElapsedEventArgs elapsedEventArgs) { // Verify that the directory exists Directory.CreateDirectory(SaveDataDirectoryPath); foreach (var entry in MenuInstances) { // Serialize current data var data = new Dictionary <string, List <Dictionary <string, object> > >(); foreach (var menu in entry.Value) { data[menu.UniqueMenuId] = menu.ValueContainer.Serialize(); } // Verify that there is data to save if (data.Count > 0) { // Merge previous data with current data var dataToSave = SavedValues.ContainsKey(entry.Key) ? SavedValues[entry.Key] : new Dictionary <string, List <Dictionary <string, object> > >(); foreach (var entryKeys in data) { dataToSave[entryKeys.Key] = entryKeys.Value; } // Get the file path var filePath = Path.Combine(SaveDataDirectoryPath, entry.Key + ".json"); var fileBackupPath = filePath + ".backup"; // Create a backup of the current file if (File.Exists(filePath)) { File.Copy(filePath, fileBackupPath, true); } try { // Write content to the file File.WriteAllText(filePath, JsonConvert.SerializeObject(dataToSave)); } catch (Exception e) { // Restore the backup if (File.Exists(fileBackupPath)) { Logger.Warn("Error during config file writing, restoring backup!"); File.Copy(fileBackupPath, filePath, true); } } // Delete the backup file File.Delete(fileBackupPath); } } }
// Use this for initialization void Start() { Text[] ts = GetComponentsInChildren<Text>(); foreach (var t in ts) { if (t.name == "Enemies") enemies = t; if (t.name == "Computers") computers = t; } victory = GameObject.FindGameObjectWithTag("Victory"); victory.SetActive(false); pause = GameObject.FindGameObjectWithTag("Pause"); pause.SetActive(false); sv = GameObject.FindObjectOfType<SavedValues>(); Cursor.visible = false; }
//this method will be called when load process is done private void LoadComplete(SavedValues data, SaveResult result, string message) { //result is success-> load your saved data into variables if (result == SaveResult.Success) { savedValues = data; } //if for some reason your load failed, create an empty data to work with inside your game or give a message to the user if (result == SaveResult.Error || result == SaveResult.EmptyData) { savedValues = new SavedValues(); } //after load is done refresh the UI RefreshUI(); }
// Use this for initialization void Start() { sv = FindObjectOfType<SavedValues>(); }
// Use this for initialization void Start() { Time.timeScale = 1f; sv = FindObjectOfType<SavedValues>(); }
void Start() { sv = GameObject.FindObjectOfType<SavedValues>(); // Call the Spawn function after a delay of the spawnTime and then continue to call after the same amount of time. InvokeRepeating("Spawn", 10f, 10f); }
IEnumerator Start() { sv = FindObjectOfType<SavedValues>(); wayPointArray = sv.getWayPoints(); nav = GetComponent<NavMeshAgent>(); _playScare = Camera.main.GetComponent<SoundScript>().PlayAware; while (true) yield return StartCoroutine(HuntingState()); }
// Use this for initialization void Start() { sv = FindObjectOfType<SavedValues>(); this.gameObject.SetActive(false); }
// Use this for initialization void Start() { _renderer = GetComponent<Renderer>(); sv = FindObjectOfType<SavedValues>(); }