public static void AutoMakeUILuaScripts() { var windowAssets = GameObject.FindObjectsOfType <UIWindowAsset>(); if (windowAssets.Length > 0) { foreach (var windowAsset in windowAssets) { var uiName = windowAsset.name; var scriptPath = $"{KResourceModule.EditorProductFullPath}/{AppConfig.LuaPath}/UI/{uiName}/{uiName}.lua"; if (!File.Exists(scriptPath)) { var scriptDir = Path.GetDirectoryName(scriptPath); if (!string.IsNullOrEmpty(scriptDir) && Directory.Exists(scriptDir) == false) { Directory.CreateDirectory(scriptDir); } File.WriteAllText(scriptPath, LuaUITempalteCode.Replace("$UI_NAME", uiName)); Debug.Log("New Lua Script: " + scriptPath); } else { Debug.Log("Exists Lua Script, ignore: " + scriptPath); } } } else { Debug.LogError("Not found any `UIWindowAsset` Component"); } }
public static void AutoMakeUILuaScripts() { var luaPath = AppEngine.GetConfig("KSFramework.Lua", "LuaPath"); Debug.Log("Find UI from current scenes, LuaScriptPath: " + luaPath); var windowAssets = GameObject.FindObjectsOfType <UIWindowAsset>(); if (windowAssets.Length > 0) { foreach (var windowAsset in windowAssets) { var uiName = windowAsset.name; var scriptPath = string.Format("{0}/{1}/UI/UI{2}.lua", KResourceModule.EditorProductFullPath, luaPath, uiName); if (!File.Exists(scriptPath)) { File.WriteAllText(scriptPath, LuaUITempalteCode.Replace("$UI_NAME", "UI" + uiName)); Debug.LogWarning("New Lua Script: " + scriptPath); } else { Debug.Log("Exists Lua Script, ignore: " + scriptPath); } } } else { Debug.LogError("Not found any `UIWindowAsset` Component"); } }