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

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