private static void LoadTemplates() { List <TemplateEntry> templates = TemplateManagerDAO.Load(); if (templates.Count != Templates.Count) { Templates = templates; } }
static void Open() { NewScriptWindow.template = TemplateManagerDAO.Load().Find(t => t.Name.Equals("Scriptable Object")); EditorWindow.GetWindow <NewScriptWindow>(NewScriptWindow.template.Name, true, new Type[] { Type.GetType("UnityEditor.SceneView,UnityEditor.dll") }); }
private void DrawControls() { GUILayout.BeginHorizontal(); // If in creation mode if (isEditMode || isCreateMode) { // Can't save an invalid template if (GUILayout.Button("Save", GUILayout.Width(100))) { if (isEditMode) { if (Regex.IsMatch(SelectedTemplate.Name, @"^\d")) { Debug.LogError("This template name should not start with a number."); } else if (string.IsNullOrWhiteSpace(SelectedTemplate.Name)) { Debug.LogError("This template name is mandatory."); } else { UpdateTemplate(); isEditMode = false; } } else { if (TemplateManagerDAO.Load().Exists(t => t.Name.Equals(SelectedTemplate.Name))) { Debug.LogError("This template name is already taken."); } else if (string.IsNullOrWhiteSpace(SelectedTemplate.Name)) { Debug.LogError("This template name is mandatory."); } else if (Regex.IsMatch(SelectedTemplate.Name, @"^\d")) { Debug.LogError("This template name should not start with a number."); } else { SaveNewTempalte(); isCreateMode = false; } } } if (GUILayout.Button("Abord", GUILayout.Width(100))) { SelectedTemplate = Templates[selectedIndex]; isEditMode = false; isCreateMode = false; } } else { // Add control to edit/delete selected template or create a new one if (GUILayout.Button("Create", GUILayout.Width(100))) { CreateTemplate(); isCreateMode = true; } // Can't edit or remove non existing template EditorGUI.BeginDisabledGroup(Templates.Count == 0); if (GUILayout.Button("Edit", GUILayout.Width(100))) { isEditMode = true; } if (GUILayout.Button("Delete", GUILayout.Width(100))) { DeleteTemplate(); } EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); }