예제 #1
0
        /// <summary>
        /// Saves the SOFlow text area data.
        /// </summary>
        public static void SaveTextAreaData()
        {
            TextAreaList textAreaData = new TextAreaList();

            foreach (KeyValuePair <int, TextAreaData> data in _textAreas)
            {
                textAreaData.TextAreaData.Add(data.Value);
            }

            try
            {
                File.WriteAllText(Path.Combine(Application.persistentDataPath, _textAreasFile),
                                  EditorJsonUtility.ToJson(textAreaData));
            }
            catch (Exception e)
            {
                Debug.LogError($"Failed to save text area data.\n\n{e.Message}");
            }
        }
예제 #2
0
        public static void LoadTextAreaData()
        {
            try
            {
                string filePath = Path.Combine(Application.persistentDataPath, _textAreasFile);

                if (File.Exists(filePath))
                {
                    _textAreas.Clear();

                    TextAreaList textAreaData = new TextAreaList();
                    EditorJsonUtility.FromJsonOverwrite(File.ReadAllText(filePath), textAreaData);

                    foreach (TextAreaData data in textAreaData.TextAreaData)
                    {
                        _textAreas.Add(data.TextAreaID, data);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError($"Failed to load text area data.\n\n{e.Message}");
            }
        }