public void LoadOptionData() { string optionfilePath = Application.persistentDataPath + "/optionData.json"; try { //File.ReadAllText(Application.dataPath + "/optionData.json"); if (File.Exists(optionfilePath)) { string str_optiondata = File.ReadAllText(optionfilePath); g_optiondata = JsonUtility.FromJson <Option_data>(str_optiondata); } else { g_optiondata.SetOption(true, true); File.WriteAllText(optionfilePath, JsonUtility.ToJson(g_optiondata, true)); } } catch (FileNotFoundException e) { Debug.Log("The file was not found:" + e.Message); } catch (DirectoryNotFoundException e) { Debug.Log("The directory was not found: " + e.Message); } catch (IOException e) { Debug.Log("The file could not be opened:" + e.Message); } }
public void SaveOptionData(Option_data toSaveData) { string optionfilePath = Application.persistentDataPath + "/optionData.json"; File.WriteAllText(optionfilePath, JsonUtility.ToJson(toSaveData, true)); }