public static void CleanRecord(string recordName) { RecordTable table = GetData(recordName); table.Clear(); SaveData(recordName, table); }
/// <summary> /// 根据RecordName获取数据,初次从文件中找Json数据 /// </summary> /// <param name="recordName"></param> /// <returns></returns> public static RecordTable GetData(string recordName) { if (s_recordCache.ContainsKey(recordName)) { return(s_recordCache[recordName]); } RecordTable record = null; string dataJson = ""; string fullPath = PathTool.GetAbsolutePath(ResLoadLocation.Persistent, PathTool.GetRelativelyPath(DirectoryName, recordName, ExpandName)); if (File.Exists(fullPath)) { dataJson = ResourceIOTool.ReadStringByFile(fullPath); } if (dataJson == "") { record = new RecordTable(); } else { record = RecordTable.Analysis(dataJson); } s_recordCache.Add(recordName, record); return(record); }
public static void SaveRecord(string recordName, string key, float value) { RecordTable table = GetData(recordName); table.SetRecord(key, value); SaveData(recordName, table); }
public static void SaveRecord(string RecordName, string key, Color value) { RecordTable table = GetData(RecordName); table.SetRecord(key, value); SaveData(RecordName, table); }
/// <summary> /// Json2RecordTable /// </summary> /// <param name="data"></param> /// <returns></returns> public static RecordTable Analysis(string data) { RecordTable result = new RecordTable(); Dictionary <string, SingleField> temp = JsonTool.Json2Dictionary <SingleField>(data); List <string> keys = new List <string>(temp.Keys); for (int i = 0; i < keys.Count; i++) { result.Add(keys[i], temp[keys[i]]); } return(result); }
public static void SaveData(string recordName, RecordTable table) { #if !UNITY_WEBGL ResourceIOTool.WriteStringByFile( PathTool.GetAbsolutePath(ResLoadLocation.Persistent, PathTool.GetRelativelyPath(DirectoryName, recordName, ExpandName)), RecordTable.Serialize(table)); #if UNITY_EDITOR if (!Application.isPlaying) { UnityEditor.AssetDatabase.Refresh(); } #endif #endif }
public static Color GetColorRecord(string RecordName, string key, Color defaultValue) { RecordTable table = GetData(RecordName); return(table.GetRecord(key, defaultValue)); }
public static Vector3 GetVector3Record(string RecordName, string key, Vector3 defaultValue) { RecordTable table = GetData(RecordName); return(table.GetRecord(key, defaultValue)); }
public static bool GetBoolRecord(string RecordName, string key, bool defaultValue) { RecordTable table = GetData(RecordName); return(table.GetRecord(key, defaultValue)); }
public static int GetIntRecord(string RecordName, string key, int defaultValue) { RecordTable table = GetData(RecordName); return(table.GetRecord(key, defaultValue)); }
/// <summary> /// 获取浮点记录值 /// </summary> /// <param name="recordName"></param> /// <param name="key"></param> /// <param name="defaultKey"></param> /// <returns></returns> public static float GetFloatRecord(string recordName, string key, float defaultKey) { RecordTable table = GetData(recordName); return(table.GetRecord(key, defaultKey)); }
/// <summary> /// Dictionary2Json /// </summary> /// <param name="table"></param> /// <returns></returns> public static string Serialize(RecordTable table) { return(JsonTool.Dictionary2Json <SingleField>(table)); }