Exemple #1
0
        /// <summary>
        /// Saves the SOFlow numeric slider data.
        /// </summary>
        public static void SaveNumericSliderData()
        {
            NumericSliderList sliderData = new NumericSliderList();

            foreach (KeyValuePair <int, NumericSliderData> data in _numericSliders)
            {
                sliderData.SliderData.Add(data.Value);
            }

            try
            {
                File.WriteAllText(Path.Combine(Application.persistentDataPath, _numericSlidersFile), EditorJsonUtility.ToJson(sliderData));
            }
            catch (Exception e)
            {
                Debug.LogError($"Failed to save numeric slider data.\n\n{e.Message}");
            }
        }
Exemple #2
0
        public static void LoadNumericSliderData()
        {
            try
            {
                string filePath = Path.Combine(Application.persistentDataPath, _numericSlidersFile);

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

                    NumericSliderList sliderData = new NumericSliderList();
                    EditorJsonUtility.FromJsonOverwrite(File.ReadAllText(filePath), sliderData);

                    foreach (NumericSliderData data in sliderData.SliderData)
                    {
                        _numericSliders.Add(data.SliderID, data);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError($"Failed to load numeric slider data.\n\n{e.Message}");
            }
        }