//加载解析看板娘所需配置 static void LoadConfig() { animationDic.Clear(); posterDic.Clear(); if (!File.Exists(AnimatorConfigPath)) { Debug.LogError("找不到数据:" + AnimatorConfigPath); return; } var data = GetTextFromFile(AnimatorConfigPath); var json = Json2TableTools.GetJsonFromLua(data); var jsonData = JsonMapper.ToObject <Dictionary <string, PosterAnimationData> >(json); foreach (var item in jsonData) { animationDic.Add(int.Parse(item.Key), item.Value); int avatar_id = item.Value.AvatarID; List <PosterAnimationData> poster_list; if (!posterDic.TryGetValue(avatar_id, out poster_list)) { poster_list = new List <PosterAnimationData>(); posterDic.Add(avatar_id, poster_list); } poster_list.Add(item.Value); } }
public static void TestLua2Json() { string path = Application.dataPath + "/Text/Config.lua"; using (FileStream file = new FileStream(path, FileMode.Open)) using (StreamReader reader = new StreamReader(file)) { var context = reader.ReadToEnd(); Debug.Log(Json2TableTools.GetJsonFromLua(context)); } }
public static Dictionary <string, CharacterConfig> LoadConfig() { var context = ""; var configJson = ""; using (FileStream file = new FileStream(configPath, FileMode.Open)) using (StreamReader reader = new StreamReader(file)) { context = reader.ReadToEnd(); } //Debug.Log(context); if (!string.IsNullOrEmpty(context)) { configJson = Json2TableTools.GetJsonFromLua(context); } //Debug.Log(configJson); Data = JsonMapper.ToObject <Dictionary <string, CharacterConfig> >(configJson); //Debug.Log(string.Concat("test: ", Data.ToString())); //Debug.Log(GetModelPath(1, "PosterModel.body")); return(Data); }