public virtual void CreateEditors() { editors.Clear(); mainEmptyEditor = new EmptyEditor("Items editor", this); mainEmptyEditor.childEditors.Add(new SightTargetCategoryEditor("Category", "Categories", this)); editors.Add(mainEmptyEditor); editors.Add(new SettingsEditor("Settings", "Settings", this)); }
public virtual void CreateEditors() { editors.Clear(); itemEditor = new EmptyEditor(QuestSystemPro.ProductName + " - Main editor", this) { requiresDatabase = true }; itemEditor.childEditors.Add(new QuestsEditor("Quest", "Quests", this)); itemEditor.childEditors.Add(new AchievementsEditor("Achievement", "Achievements", this)); editors.Add(itemEditor); settingsEditor = new SettingsEditor("Settings", "Settings categories", this); editors.Add(settingsEditor); }
// public static void SelectPage(string path) // { // throw new NotImplementedException(); // } public virtual void CreateEditors() { _editors.Clear(); var dict = new Dictionary <string, EmptyEditor>(); var foundEditors = ReflectionUtility.GetAllClassesWithAttribute(typeof(EditorPageAttribute), true).ToList(); foundEditors.Sort((a, b) => { var first = (EditorPageAttribute)a.GetCustomAttributes(typeof(EditorPageAttribute), true).First(); var second = (EditorPageAttribute)b.GetCustomAttributes(typeof(EditorPageAttribute), true).First(); if (first.order > second.order) { return(1); } else if (first.order < second.order) { return(-1); } return(0); }); foreach (var foundEditor in foundEditors) { var attribute = (EditorPageAttribute)foundEditor.GetCustomAttributes(typeof(EditorPageAttribute), true).First(); var pathSplit = attribute.path.Split('/'); if (pathSplit.Length == 1 || pathSplit.Length == 2) { if (dict.ContainsKey(pathSplit[0]) == false) { dict[pathSplit[0]] = new EmptyEditor(pathSplit[0], this); } var constructor = foundEditor.GetConstructor(new[] { typeof(EditorWindow) }); if (constructor != null) { var inst = (IEditorCrud)constructor.Invoke(new object[] { this }); dict[pathSplit[0]].childEditors.Add(inst); } else { Debug.Log("[Editor] Couldn't initialize editor page, constructor needs to take 1 argument (EditorWindow): parent", this); } } else { Debug.Log("[Editor] Couldn't initialize editor with attribute path: " + attribute.path, this); } } _editors.AddRange(dict.Select(o => o.Value)); _toolbarIndex = 0; if (_editors.Count > _toolbarIndex) { _editors[_toolbarIndex].Focus(); } }