private void DrawSettings() { using (var hor = new EditorGUILayout.HorizontalScope()) { EditorGUI.BeginChangeCheck(); EditorGUILayout.SelectableLabel("作者:", EditorStyles.miniLabel, GUILayout.Width(60)); authorName = EditorGUILayout.TextField(authorName); if (EditorGUI.EndChangeCheck()) { if (!string.IsNullOrEmpty(authorName)) { TempScriptHelper.SaveAuthor(authorName); } } } EditorGUI.BeginChangeCheck(); showRule = EditorGUILayout.ToggleLeft("在生成的代码末尾显示规范:(熟悉后可关闭此功能)", showRule); if (EditorGUI.EndChangeCheck()) { TempScriptHelper.SetRuleShowState(showRule); } if (showRule) { using (var scrop = new EditorGUILayout.ScrollViewScope(scrollPos)) { scrollPos = scrop.scrollPosition; EditorGUILayout.TextArea(codeRule); } } }
protected string GetFooter() { if (TempScriptHelper.GetRuleShowState()) { var rule = TempScriptHelper.GetCodeRule(); return(rule); } return(null); }
private void OnDisable() { if (templates != null) { foreach (var item in templates) { item.SaveToJson(); } } EditorUtility.SetDirty(this); TempScriptHelper.SaveWindow(this); }
private void InitEnviroment() { if (script == null) { script = MonoScript.FromScriptableObject(this); } showRule = TempScriptHelper.GetRuleShowState(); if (string.IsNullOrEmpty(codeRule)) { codeRule = TempScriptHelper.GetCodeRule(); } if (string.IsNullOrEmpty(authorName)) { authorName = TempScriptHelper.GetAuthor(); } if (string.IsNullOrEmpty(authorName)) { isSetting = true; } }
public void LoadOldTemplates() { for (int i = 0; i < templates.Count; i++) { if (templates[i] == null) { Debug.LogFormat("templates[{0}] == null", i); templates.Clear(); return; } var newitem = TempScriptHelper.LoadFromJson(templates[i]); if (newitem == null) { Debug.LogFormat("newitem[{0}] == null", i); templates.Clear(); return; } templates[i] = newitem; } templateNames = templates.ConvertAll <string>(x => x.Name).ToArray(); templateType = templates.ConvertAll <string>(x => x.GetType().FullName).ToArray(); }
static void CreateModel() { TempScriptHelper.QuickCreateTemplate <DataModelTemplate>(); }
static void CreateEnum() { TempScriptHelper.QuickCreateTemplate <EnumScriptTemplate>(); }
private void OnGUI() { DrawHead(); if (isSetting) { //绘制设置信息 DrawSettings(); } else { if (templates == null) { Debug.Log("template == null"); templates = new List <ScriptTemplate>(); } if (templates.Count == 0) { Debug.Log("AddTemplates"); AddTemplates(); } currentIndex = GUILayout.Toolbar(currentIndex, templateNames); using (var scroll = new EditorGUILayout.ScrollViewScope(scrollPos)) { scrollPos = scroll.scrollPosition; if (currentTemplates != null) { if (currentTemplates.GetType().FullName != currentTemplates.type) { templates[currentIndex] = TempScriptHelper.LoadFromJson(currentTemplates); } currentTemplates.OnBodyGUI(); if (currentTemplates.GetType().FullName == typeof(ScriptTemplate).FullName) { if (templateType.Length > currentIndex) { var type = Type.GetType(templateType[currentIndex]); if (type != null) { templates[currentIndex] = Activator.CreateInstance(type) as ScriptTemplate; Debug.Log("create new:" + currentTemplates.GetType()); } else { Debug.LogFormat("{0} missing: clear templates", currentTemplates.GetType().FullName); templates.Clear(); } } else { Debug.Log("unknow err: clear templates"); templates.Clear(); } } } else { templates.Clear(); Debug.Log("templates.Count <= currentIndex"); } } if (currentTemplates != null) { currentTemplates.OnFootGUI(); } } }
static void Open() { var window = TempScriptHelper.GetWindow(); window.wantsMouseMove = true; }
public void Update() { author = TempScriptHelper.GetAuthor(); time = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); }
static void CreateEnum() { TempScriptHelper.QuickCreateTemplate <ScriptableObjTempate>(); }
static void CreateEnum() { TempScriptHelper.QuickCreateTemplate <MonoBehaiverTemplate>(); }
static void CreateEnum() { TempScriptHelper.QuickCreateTemplate <InterfaceTempate>(); }
static void CreateStruct() { TempScriptHelper.QuickCreateTemplate <StructTempate>(); }