Пример #1
0
        public static void LoadJsonData(string _path, ref Dictionary <K, D> _refDico)
        {
            SerializedMap <K, D> fromLoad = JsonUtility.FromJson <SerializedMap <K, D> >(File.ReadAllText(_path));

            for (int i = 0; i < fromLoad.m_keysData.Count; i++)
            {
                _refDico[fromLoad.m_keysData[i]] = fromLoad.m_keyCodeData[i];
            }
        }
Пример #2
0
        public static void SaveJsonData(string _path, ref Dictionary <K, D> _refDico)
        {
            SerializedMap <K, D> data = new SerializedMap <K, D>();

            foreach (K key in _refDico.Keys)
            {
                data.m_keysData.Add(key);
                data.m_keyCodeData.Add(_refDico[key]);
            }

            if (File.Exists(_path))
            {
                string dataAsJson = JsonUtility.ToJson(data);
                File.WriteAllText(_path, dataAsJson);
            }
            else
            {
                File.Create(_path);
                string dataAsJson = JsonUtility.ToJson(data);
                File.WriteAllText(_path, dataAsJson);
            }
        }