/// <summary> /// read constants method. Returns true if successful, false otherwise /// </summary> public bool ReadConstantsFromFile() { bool isSuccess = false; if (string.IsNullOrEmpty(filenameConstants) == false) { if (File.Exists(filenameConstants) == true) { //read data from File try { jsonRead = File.ReadAllText(filenameConstants); } catch (Exception e) { Debug.LogErrorFormat("Failed to read TEXT FROM FILE, error \"{0}\"", e.Message); } isSuccess = true; if (isSuccess == true) { //read to Save file try { readConstantsJSON = JsonUtility.FromJson <SaveConstants>(jsonRead); Debug.LogFormat("[Fil] FileManager.cs -> ReadConstantsFromFile: GAME LOADED from \"{0}\"{1}", filenameConstants, "\n"); return(true); } catch (Exception e) { Debug.LogErrorFormat("Failed to read Json, error \"{0}\"", e.Message); } } } else { Debug.LogWarningFormat("File \"{0}\" not found", filenameConstants); } } else { Debug.LogError("Invalid filename (Null or Empty)"); } return(false); }
// // - - - Constants File (read and write) // #region Write Constants Data /// <summary> /// copy inGame data to saveData /// </summary> public void WriteConstantsData() { writeConstantsJSON = new SaveConstants(); //Sequentially write data WriteConstantPlotpoints(); }