Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
 protected string GetFooter()
 {
     if (TempScriptHelper.GetRuleShowState())
     {
         var rule = TempScriptHelper.GetCodeRule();
         return(rule);
     }
     return(null);
 }
Exemple #3
0
 private void OnDisable()
 {
     if (templates != null)
     {
         foreach (var item in templates)
         {
             item.SaveToJson();
         }
     }
     EditorUtility.SetDirty(this);
     TempScriptHelper.SaveWindow(this);
 }
Exemple #4
0
 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;
     }
 }
Exemple #5
0
        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();
        }
Exemple #6
0
 static void CreateModel()
 {
     TempScriptHelper.QuickCreateTemplate <DataModelTemplate>();
 }
Exemple #7
0
 static void CreateEnum()
 {
     TempScriptHelper.QuickCreateTemplate <EnumScriptTemplate>();
 }
Exemple #8
0
        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();
                }
            }
        }
Exemple #9
0
        static void Open()
        {
            var window = TempScriptHelper.GetWindow();

            window.wantsMouseMove = true;
        }
Exemple #10
0
 public void Update()
 {
     author = TempScriptHelper.GetAuthor();
     time   = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
 }
Exemple #11
0
 static void CreateEnum()
 {
     TempScriptHelper.QuickCreateTemplate <ScriptableObjTempate>();
 }
Exemple #12
0
 static void CreateEnum()
 {
     TempScriptHelper.QuickCreateTemplate <MonoBehaiverTemplate>();
 }
Exemple #13
0
 static void CreateEnum()
 {
     TempScriptHelper.QuickCreateTemplate <InterfaceTempate>();
 }
Exemple #14
0
 static void CreateStruct()
 {
     TempScriptHelper.QuickCreateTemplate <StructTempate>();
 }