static void CacheVariableTypes() { var derivedType = typeof(Variable); _variableTypes = EditorExtensions.FindDerivedTypes(derivedType) .Where(x => !x.IsAbstract && derivedType.IsAssignableFrom(x)) .ToList(); }
protected virtual void ShowCommandMenu() { var block = target as Block; var flowchart = (Flowchart)block.GetFlowchart(); // Use index of last selected command in list, or end of list if nothing selected. int index = -1; foreach (var command in flowchart.SelectedCommands) { if (command.CommandIndex + 1 > index) { index = command.CommandIndex + 1; } } if (index == -1) { index = block.CommandList.Count; } GenericMenu commandMenu = new GenericMenu(); // Build menu list List <System.Type> menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList(); List <KeyValuePair <System.Type, CommandInfoAttribute> > filteredAttributes = GetFilteredCommandInfoAttribute(menuTypes); filteredAttributes.Sort(CompareCommandAttributes); foreach (var keyPair in filteredAttributes) { // Skip command type if the Flowchart doesn't support it if (!flowchart.IsCommandSupported(keyPair.Value)) { continue; } AddCommandOperation commandOperation = new AddCommandOperation(); commandOperation.block = block; commandOperation.commandType = keyPair.Key; commandOperation.index = index; GUIContent menuItem; if (keyPair.Value.Category == "") { menuItem = new GUIContent(keyPair.Value.CommandName); } else { menuItem = new GUIContent(keyPair.Value.Category + "/" + keyPair.Value.CommandName); } commandMenu.AddItem(menuItem, false, AddCommandCallback, commandOperation); } commandMenu.ShowAsContext(); }
private static void ExportCommandInfo() { // Dump command info List <System.Type> menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList(); List <KeyValuePair <System.Type, CommandInfoAttribute> > filteredAttributes = BlockEditor.GetFilteredCommandInfoAttribute(menuTypes); filteredAttributes.Sort(BlockEditor.CompareCommandAttributes); // Build list of command categories List <string> commandCategories = new List <string>(); foreach (var keyPair in filteredAttributes) { CommandInfoAttribute info = keyPair.Value; if (info.Category != "" && !commandCategories.Contains(info.Category)) { commandCategories.Add(info.Category); } } commandCategories.Sort(); var sb = new System.Text.StringBuilder(@"# Command Reference This is the reference documentation for all Fungus commands. "); // Output the commands in each category foreach (string category in commandCategories) { string markdown = "# " + category + " commands # {#" + category.ToLower() + "_commands}\n\n"; markdown += "[TOC]\n"; foreach (var keyPair in filteredAttributes) { CommandInfoAttribute info = keyPair.Value; if (info.Category == category || info.Category == "" && category == "Scripting") { markdown += "# " + info.CommandName + " # {#" + info.CommandName.Replace(" ", "") + "}\n"; markdown += info.HelpText + "\n\n"; markdown += "Defined in " + keyPair.Key.FullName + "\n"; markdown += GetPropertyInfo(keyPair.Key); } } WriteFile(markdown, CommandRefDocPath, category.ToLower(), "_commands.md"); sb.Append("* [").Append(category).Append("](").Append(category.ToLower()).AppendLine("_commands)"); } sb.AppendLine(); WriteFile(sb.ToString(), BaseDocPath, "", "command_reference.md"); }
private static void ExportEventHandlerInfo() { List <System.Type> eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList(); List <string> eventHandlerCategories = new List <string>(); eventHandlerCategories.Add("Core"); foreach (System.Type type in eventHandlerTypes) { EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type); if (info != null && info.Category != "" && !eventHandlerCategories.Contains(info.Category)) { eventHandlerCategories.Add(info.Category); } } eventHandlerCategories.Sort(); var sb = new System.Text.StringBuilder(@"# Event Handler Reference {#eventhandler_reference} This is the reference documentation for all Fungus event handlers. "); // Output the commands in each category foreach (string category in eventHandlerCategories) { string markdown = "# " + category + " event handlers # {#" + category.ToLower() + "_events}\n\n"; markdown += "[TOC]\n"; foreach (System.Type type in eventHandlerTypes) { EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type); if (info != null && (info.Category == category || (info.Category == "" && category == "Core"))) { markdown += "# " + info.EventHandlerName + " # {#" + info.EventHandlerName.Replace(" ", "") + "}\n"; markdown += info.HelpText + "\n\n"; markdown += "Defined in " + type.FullName + "\n"; markdown += GetPropertyInfo(type); } } WriteFile(markdown, CommandRefDocPath, category.ToLower(), "_events.md"); sb.Append("* [").Append(category).Append("](").Append(category.ToLower()).AppendLine("_events)"); } sb.AppendLine(); WriteFile(sb.ToString(), BaseDocPath, "", "eventhandler_reference.md"); }
protected static void ExportCommandInfo(string path) { // Dump command info List <System.Type> menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList(); List <KeyValuePair <System.Type, CommandInfoAttribute> > filteredAttributes = GetFilteredCommandInfoAttribute(menuTypes); filteredAttributes.Sort(CompareCommandAttributes); // Build list of command categories List <string> commandCategories = new List <string>(); foreach (var keyPair in filteredAttributes) { CommandInfoAttribute info = keyPair.Value; if (info.Category != "" && !commandCategories.Contains(info.Category)) { commandCategories.Add(info.Category); } } commandCategories.Sort(); // Output the commands in each category foreach (string category in commandCategories) { string markdown = "# " + category + " commands # {#" + category.ToLower() + "_commands}\n\n"; markdown += "[TOC]\n"; foreach (var keyPair in filteredAttributes) { CommandInfoAttribute info = keyPair.Value; if (info.Category == category || info.Category == "" && category == "Scripting") { markdown += "# " + info.CommandName + " # {#" + info.CommandName.Replace(" ", "") + "}\n"; markdown += info.HelpText + "\n\n"; markdown += "Defined in " + keyPair.Key.FullName + "\n"; markdown += GetPropertyInfo(keyPair.Key); } } string filePath = path + "/command_ref/" + category.ToLower() + "_commands.md"; Directory.CreateDirectory(Path.GetDirectoryName(filePath)); File.WriteAllText(filePath, markdown); } }
protected static void ExportEventHandlerInfo(string path) { List <System.Type> eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList(); List <string> eventHandlerCategories = new List <string>(); eventHandlerCategories.Add("Core"); foreach (System.Type type in eventHandlerTypes) { EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type); if (info != null && info.Category != "" && !eventHandlerCategories.Contains(info.Category)) { eventHandlerCategories.Add(info.Category); } } eventHandlerCategories.Sort(); // Output the commands in each category foreach (string category in eventHandlerCategories) { string markdown = "# " + category + " event handlers # {#" + category.ToLower() + "_events}\n\n"; markdown += "[TOC]\n"; foreach (System.Type type in eventHandlerTypes) { EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type); if (info != null && (info.Category == category || (info.Category == "" && category == "Core"))) { markdown += "# " + info.EventHandlerName + " # {#" + info.EventHandlerName.Replace(" ", "") + "}\n"; markdown += info.HelpText + "\n\n"; markdown += "Defined in " + type.FullName + "\n"; markdown += GetPropertyInfo(type); } } string filePath = path + "/command_ref/" + category.ToLower() + "_events.md"; Directory.CreateDirectory(Path.GetDirectoryName(filePath)); File.WriteAllText(filePath, markdown); } }
static void CacheCommandTypes() { commandTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).Where(x => !x.IsAbstract).ToList(); }
protected virtual void DrawEventHandlerGUI(Flowchart flowchart) { // Show available Event Handlers in a drop down list with type of current // event handler selected. List <System.Type> eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList(); Block block = target as Block; System.Type currentType = null; if (block._EventHandler != null) { currentType = block._EventHandler.GetType(); } string currentHandlerName = "<None>"; if (currentType != null) { EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(currentType); if (info != null) { currentHandlerName = info.EventHandlerName; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Execute On Event")); if (GUILayout.Button(new GUIContent(currentHandlerName), EditorStyles.popup)) { SetEventHandlerOperation noneOperation = new SetEventHandlerOperation(); noneOperation.block = block; noneOperation.eventHandlerType = null; GenericMenu eventHandlerMenu = new GenericMenu(); eventHandlerMenu.AddItem(new GUIContent("None"), false, OnSelectEventHandler, noneOperation); // Add event handlers with no category first foreach (System.Type type in eventHandlerTypes) { EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type); if (info != null && info.Category.Length == 0) { SetEventHandlerOperation operation = new SetEventHandlerOperation(); operation.block = block; operation.eventHandlerType = type; eventHandlerMenu.AddItem(new GUIContent(info.EventHandlerName), false, OnSelectEventHandler, operation); } } // Add event handlers with a category afterwards foreach (System.Type type in eventHandlerTypes) { EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type); if (info != null && info.Category.Length > 0) { SetEventHandlerOperation operation = new SetEventHandlerOperation(); operation.block = block; operation.eventHandlerType = type; string typeName = info.Category + "/" + info.EventHandlerName; eventHandlerMenu.AddItem(new GUIContent(typeName), false, OnSelectEventHandler, operation); } } eventHandlerMenu.ShowAsContext(); } EditorGUILayout.EndHorizontal(); if (block._EventHandler != null) { EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(block._EventHandler) as EventHandlerEditor; if (eventHandlerEditor != null) { eventHandlerEditor.DrawInspectorGUI(); DestroyImmediate(eventHandlerEditor); } } }
static void CacheEventHandlerTypes() { _eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).Where(x => !x.IsAbstract).ToList(); }
static void CacheEventHandlerTypes() { eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList(); commandTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList(); }