예제 #1
0
        public void Save(IEnumerable <PulseSetting> pulseSettings)
        {
            var target = new PulseSettingListForSerialize(pulseSettings);

            var json = JsonUtility.ToJson(target);

            using (var sw = new StreamWriter(JsonFilePath, false))
            {
                try
                {
                    sw.Write(json);
                }
                catch (Exception e)
                {
                    Debug.Log(e);
                }
            }

            Debug.Log($"Saved : {JsonFilePath}");
        }
예제 #2
0
        public IEnumerable <PulseSetting> Load()
        {
            var jsonDeserializedData = new PulseSettingListForSerialize();

            try
            {
                using (var fs = new FileStream(JsonFilePath, FileMode.OpenOrCreate))
                    using (var sr = new StreamReader(fs))
                    {
                        var result = sr.ReadToEnd();

                        jsonDeserializedData = JsonUtility.FromJson <PulseSettingListForSerialize>(result);
                    }
            }
            catch (Exception e)
            {
                Debug.Log(e);
            }

            return(jsonDeserializedData.Data);
        }