public static void GenerateCode() { UICodeGenerator.GetSelectedUI(out var goes, out var paths, out var guids); UICodeGenerator.TypeMap.Clear(); var length = param.types.Count; for (var i = 0; i < length; i++) { UICodeGenerator.TypeMap.Add(param.typesName[i], param.types[i]); } UICodeGenerator.Separator = param.separator; // 读取模板 param.template = Framework.Util.FileUtil.ReadFileToString(Application.dataPath + "/" + param.templatePath); for (var j = 0; j < goes.Count; j++) { var code = UICodeGenerator.GenerateUICode(goes[j], paths[j], guids[j], param); if (string.IsNullOrEmpty(code)) { Debug.LogError($"failed to generate {paths[j]} code"); return; } var relatedPath = paths[j].Replace(param.uiRootPath, string.Empty); var codePath = Application.dataPath + "/" + param.codeRootPath + "/" + relatedPath + ".cs"; codePath = codePath.Remove(codePath.IndexOf("Assets/"), "Assets/".Length); Framework.Util.FileUtil.WriteFile(codePath, code); Debug.Log($"generate {paths[j]} code successfully"); } }
public static void CreateHotScriptCode() { Debug.Log("<color=#EE6A50> >>>>>>>Create ToLua Code </color>"); Debug.Log(string.Format("<color=#EE6A50> >>>>>>>File Path : {0}</color>", mFilePath)); var info = new ScriptKitInfo(); info.HotScriptType = mToLua; info.HotScriptFilePath = mFilePath; info.HotScriptSuffix = mFileSuffix; info.Templates = mTemplates; info.CodeBind = mScriptCodeBind; UICodeGenerator.CreateScriptUICode(info); }
static void CreateWindow() { UICodeGenerator window = EditorWindow.GetWindow <UICodeGenerator>("脚本创建工具"); window.Show(); }