public static XLua.LuaTable LuaLoadUI(int id) { UIConfig uIConfig = UIConfigAsset.Get(id); if (uIConfig != null) { XLua.LuaTable table = (XLua.LuaTable)XLuaManager.OperationTablePool.Alloc(); table.Set("IsDone", false); table.Set("proess", 0); LuaLoadUIInternerl(table, uIConfig); return(table); } else { throw new Exception($"招不到UI路径{id}"); } }
private void GenUIConfig(Dictionary <Transform, string> goPathDic) { GUILayout.Space(10); var curSelectedParentPrefab = PrefabUtility.GetCorrespondingObjectFromSource(mUIView.gameObject); var uiPath = AssetDatabase.GetAssetPath(curSelectedParentPrefab).Replace("Assets/AssetRes/", ""); UIConfigAsset uiConfigAsset = AssetDatabase.LoadAssetAtPath <UIConfigAsset>(UIPathAssetPath); if (!uiConfigAsset) { uiConfigAsset = new UIConfigAsset(); uiConfigAsset.Configs = new UIConfig[0]; } UIConfig uiConfig = null; for (int i = 0; i < uiConfigAsset.Configs.Length; i++) { UIConfig tmpConfig = uiConfigAsset.Configs[i]; if (tmpConfig.Name == UIName) { uiConfig = tmpConfig; if (uiConfig.ID == 0) { uiConfig.ID = TimeUtility.GetTimeStampEx(); } uiConfig.Path = uiPath; break; } } if (uiConfig == null) { uiConfig = new UIConfig(); uiConfig.ID = TimeUtility.GetTimeStampEx(); uiConfig.Path = uiPath; List <UIConfig> configs = new List <UIConfig>(uiConfigAsset.Configs); configs.Add(uiConfig); uiConfigAsset.Configs = configs.ToArray(); } uiConfig.SceneName = SceneIndex == 0 ? string.Empty : SceneNames[SceneIndex]; uiConfig.AtlasNames = GetAtlasNames(goPathDic); if (File.Exists(UIPathAssetPath)) { EditorUtility.SetDirty(uiConfigAsset); } else { AssetDatabase.CreateAsset(uiConfigAsset, UIPathAssetPath); } string filePath = ""; switch (mUIView.ViewType) { case UIType.CommonView: case UIType.TabView: filePath = UIConfigPath; break; case UIType.Tips: filePath = TipsConfigPath; break; default: break; } if (File.Exists(filePath)) { string[] lines = File.ReadAllLines(filePath); int uiIndex = -1; for (int i = 0; i < lines.Length; i++) { if (lines[i].Contains(UIName)) { uiIndex = i; break; } } string newLine = ""; switch (mUIView.ViewType) { case UIType.CommonView: case UIType.TabView: newLine = $"\t{UIName} = {"{"} Name = \"{UIName}\", " + $"ID = {uiConfig.ID}, " + $"View = \"Logic/UI/View/{UIName}/{UIName}\", " + $"Layer = LayerGroup.{LayerNames[mUIView.LayerIndex]}, " + $"IsTransParent = {mUIView.IsTransParent.ToString().ToLower()}, " + $"ShowMoneyBar = {mUIView.ShowMoneyBar.ToString().ToLower()}, " + $"DestroyWhenUnload = {mUIView.DestroyOnUnload.ToString().ToLower()} {"}"},"; break; case UIType.Tips: newLine = $"\t{UIName} = {"{"} Name = \"{UIName}\", " + $"ID = {uiConfig.ID} , View = \"Logic/UI/View/{UIName}/{UIName}\"{"}"},"; break; default: break; } EditorUtility.SetDirty(mUIView); PrefabUtility.ApplyPrefabInstance(mUIView.gameObject, InteractionMode.AutomatedAction); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); if (uiIndex >= 0) { lines[uiIndex] = newLine; File.WriteAllLines(filePath, lines); } else { string[] newLines = new string[lines.Length + 1]; Array.Copy(lines, newLines, lines.Length - 1); newLines[lines.Length - 1] = newLine; newLines[lines.Length] = "}"; File.WriteAllLines(filePath, newLines); } } }