static void ShowAnimationNodeTypesMenu() { RuntimeGenericMenu menu = new RuntimeGenericMenu(); if (DashEditorCore.EditorConfig.editingGraph != null) { Type[] nodeTypes = ReflectionUtils.GetAllTypes(typeof(NodeBase)).ToArray(); foreach (Type type in nodeTypes) { CategoryAttribute attribute = type.GetCustomAttribute <CategoryAttribute>(); if (attribute == null || attribute.type != NodeCategoryType.ANIMATION) { continue; } TooltipAttribute tooltipAttribute = type.GetCustomAttribute <TooltipAttribute>(); string tooltip = tooltipAttribute != null ? tooltipAttribute.help : ""; string node = type.ToString().Substring(type.ToString().IndexOf(".") + 1); node = node.Substring(0, node.Length - 4); menu.AddItem(new GUIContent(node, tooltip), false, CreateAnimationNodesFromSelection, type); } } GenericMenuPopup.Show(menu, "", Event.current.mousePosition, 240, 300, false); }
public static void Show(DashGraph p_graph) { RuntimeGenericMenu menu = new RuntimeGenericMenu(); menu.AddItem(new GUIContent("Settings/Show Experimental"), DashEditorCore.EditorConfig.showExperimental, () => DashEditorCore.EditorConfig.showExperimental = !DashEditorCore.EditorConfig.showExperimental); menu.AddItem(new GUIContent("Settings/Show Obsolete"), DashEditorCore.EditorConfig.showObsolete, () => DashEditorCore.EditorConfig.showObsolete = !DashEditorCore.EditorConfig.showObsolete); menu.AddItem(new GUIContent("Settings/Show Node Ids"), DashEditorCore.EditorConfig.showNodeIds, () => DashEditorCore.EditorConfig.showNodeIds = !DashEditorCore.EditorConfig.showNodeIds); menu.AddItem(new GUIContent("Settings/Show Node Search"), DashEditorCore.EditorConfig.showNodeSearch, () => DashEditorCore.EditorConfig.showNodeSearch = !DashEditorCore.EditorConfig.showNodeSearch); menu.AddItem(new GUIContent("Settings/Show Node Asynchronity"), DashEditorCore.EditorConfig.showNodeAsynchronity, () => DashEditorCore.EditorConfig.showNodeAsynchronity = !DashEditorCore.EditorConfig.showNodeAsynchronity); menu.AddItem(new GUIContent("Settings/Enable Sound in Editor"), DashEditorCore.EditorConfig.enableSoundInPreview, () => DashEditorCore.EditorConfig.enableSoundInPreview = !DashEditorCore.EditorConfig.enableSoundInPreview); menu.AddItem(new GUIContent("Settings/Enable AnimateNode Interface"), DashEditorCore.EditorConfig.enableAnimateNodeInterface, () => DashEditorCore.EditorConfig.enableAnimateNodeInterface = !DashEditorCore.EditorConfig.enableAnimateNodeInterface); menu.AddSeparator(""); //menu.AddItem(new GUIContent("Advanced/Validate Serialization"), false, p_graph.ValidateSerialization); menu.AddItem(new GUIContent("Advanced/Cleanup Null"), false, p_graph.RemoveNullReferences); //menu.AddItem(new GUIContent("Advanced/Cleanup Exposed"), false, p_graph.CleanupExposedReferenceTable); menu.AddItem(new GUIContent("Reset Graph Position"), false, p_graph.ResetPosition); menu.AddItem(new GUIContent("Help"), false, () => { Application.OpenURL("https://github.com/pshtif/Dash/tree/main/Documentation"); }); //menu.ShowAsEditorMenu(); GenericMenuPopup.Show(menu, "Preferences", Event.current.mousePosition, 240, 300, false, false); }
static public void Show(GraphBox p_region) { RuntimeGenericMenu menu = new RuntimeGenericMenu(); menu.AddItem(new GUIContent("Delete Box"), false, DeleteBox, p_region); //menu.ShowAsContext(); GenericMenuPopup.Show(menu, "", Event.current.mousePosition, 200, 300, false, false); }
public static void Show(DashGraph p_graph) { RuntimeGenericMenu menu = new RuntimeGenericMenu(); menu.AddItem(new GUIContent("Import JSON"), false, () => GraphUtils.ImportJSON(p_graph)); menu.AddItem(new GUIContent("Export JSON"), false, () => GraphUtils.ExportJSON(p_graph)); //menu.ShowAsContext(); GenericMenuPopup.Show(menu, "File", Event.current.mousePosition, 240, 300, false, false); }
static RuntimeGenericMenu GetVariableMenu(DashVariables p_variables, string p_name, GameObject p_boundObject) { RuntimeGenericMenu menu = new RuntimeGenericMenu(); var variable = p_variables.GetVariable(p_name); if (variable.IsBound) { menu.AddItem(new GUIContent("Unbind"), false, () => variable.UnbindProperty()); } else { if (p_boundObject != null && !variable.IsLookup) { Dictionary <Component, List <PropertyInfo> > bindableProperties = GetBindableProperties(p_variables, p_name, p_boundObject); foreach (var infoKeys in bindableProperties) { foreach (PropertyInfo property in infoKeys.Value) { menu.AddItem(new GUIContent("Bind (Controller)/" + infoKeys.Key.name + "/" + property.Name), false, () => OnBindVariable(variable, property, infoKeys.Key)); } } Dictionary <Component, List <FieldInfo> > bindableFields = GetBindableFields(p_variables, p_name, p_boundObject); foreach (var infoKeys in bindableFields) { foreach (FieldInfo field in infoKeys.Value) { menu.AddItem(new GUIContent("Bind (Controller)/" + infoKeys.Key.name + "/" + field.Name), false, () => OnBindVariable(variable, field, infoKeys.Key)); } } } if (variable.IsLookup) { menu.AddItem(new GUIContent("Unset as Lookup"), false, () => OnLookupVariable(p_variables, p_name)); } else { menu.AddItem(new GUIContent("Set as Lookup"), false, () => OnLookupVariable(p_variables, p_name)); } } menu.AddItem(new GUIContent("Delete Variable"), false, () => OnDeleteVariable(p_variables, p_name, p_boundObject)); menu.AddItem(new GUIContent("Copy Variable"), false, () => OnCopyVariable(p_variables, p_name)); return(menu); }
static public RuntimeGenericMenu Get(Action <object> p_callback) { RuntimeGenericMenu menu = new RuntimeGenericMenu(); Type[] loadedTypes = ReflectionUtils.GetAllTypes(); foreach (Type type in loadedTypes) { string path = (string.IsNullOrEmpty(type.Namespace) ? "Without Namespace" : type.Namespace.Replace(".", "/")) + "/" + type.Name; menu.AddItem(new GUIContent(path, ""), false, p_callback, type); } return(menu); }
static public void Show(NodeConnection p_connection) { RuntimeGenericMenu menu = new RuntimeGenericMenu(); if (p_connection.active) { menu.AddItem(new GUIContent("Deactivate Connection"), false, DeactivateConnection, p_connection); } else { menu.AddItem(new GUIContent("Activate Connection"), false, ActivateConnection, p_connection); } menu.AddItem(new GUIContent("Delete Connection"), false, DeleteConnection, p_connection); //menu.ShowAsContext(); GenericMenuPopup.Show(menu, "", Event.current.mousePosition, 200, 300, false, false); }
static public RuntimeGenericMenu Get() { RuntimeGenericMenu menu = new RuntimeGenericMenu(); if (DashEditorCore.EditorConfig.editingGraph != null) { Type[] nodeTypes = ReflectionUtils.GetAllTypes(typeof(NodeBase)).ToArray(); Array.Sort(nodeTypes, CategorySort); foreach (Type type in nodeTypes) { if (IsObsolete(type) && !DashEditorCore.EditorConfig.showObsolete) { continue; } if (IsExperimental(type) && !DashEditorCore.EditorConfig.showExperimental) { continue; } if (IsHidden(type)) { continue; } if (CheckMultiple(type)) { continue; } TooltipAttribute tooltipAttribute = type.GetCustomAttribute <TooltipAttribute>(); string tooltip = tooltipAttribute != null ? tooltipAttribute.help : ""; CategoryAttribute attribute = type.GetCustomAttribute <CategoryAttribute>(); NodeCategoryType category = attribute == null ? NodeCategoryType.OTHER : attribute.type; string categoryString = category.ToString(); categoryString = categoryString.Substring(0, 1) + categoryString.Substring(1).ToLower(); string node = type.ToString().Substring(type.ToString().IndexOf(".") + 1); node = node.Substring(0, node.Length - 4); if (category == NodeCategoryType.GRAPH) { menu.AddItem(new GUIContent(node, tooltip), false, CreateNode, type); } else { menu.AddItem(new GUIContent(categoryString + "/" + node, tooltip), false, CreateNode, type); } } if (SelectionManager.HasCopiedNodes()) { menu.AddItem(new GUIContent("Paste Nodes"), false, PasteNodes); } menu.AddSeparator(""); Transform[] selectedTransforms = SelectionUtils.GetTransformsFromSelection(); if (selectedTransforms.Length > 0) { foreach (Type type in nodeTypes) { CategoryAttribute attribute = type.GetCustomAttribute <CategoryAttribute>(); if (attribute == null || attribute.type != NodeCategoryType.ANIMATION) { continue; } TooltipAttribute tooltipAttribute = type.GetCustomAttribute <TooltipAttribute>(); string tooltip = tooltipAttribute != null ? tooltipAttribute.help : ""; string node = type.ToString().Substring(type.ToString().IndexOf(".") + 1); node = node.Substring(0, node.Length - 4); menu.AddItem(new GUIContent("Create For Selected/" + node, tooltip), false, CreateAnimationNodesFromSelection, type); } } } return(menu); }
public static void Show(NodeBase p_node) { RuntimeGenericMenu menu = new RuntimeGenericMenu(); if (SelectionManager.SelectedCount > 1) { menu.AddItem(new GUIContent("Copy Nodes"), false, CopyNode, null); menu.AddItem(new GUIContent("Delete Nodes"), false, DeleteNode, null); menu.AddItem(new GUIContent("Duplicate Nodes"), false, DuplicateNode, null); menu.AddItem(new GUIContent("Create Box"), false, CreateBox); menu.AddSeparator(""); menu.AddItem(new GUIContent("Create SubGraph"), false, CreateSubGraph, null); } else { menu.AddItem(new GUIContent("Copy Node"), false, CopyNode, p_node); menu.AddItem(new GUIContent("Delete Node"), false, DeleteNode, p_node); menu.AddItem(new GUIContent("Duplicate Node"), false, DuplicateNode, p_node); menu.AddSeparator(""); if (p_node.HasComment()) { menu.AddItem(new GUIContent("Remove Comment"), false, p_node.RemoveComment); } else { menu.AddItem(new GUIContent("Create Comment"), false, p_node.CreateComment); } menu.AddSeparator(""); if (p_node is SubGraphNode) { menu.AddItem(new GUIContent("Unpack SubGraph"), false, UnpackSubGraph, p_node); } menu.AddSeparator(""); menu.AddItem(new GUIContent("Set as Preview"), false, SetAsPreview, p_node); menu.AddItem(new GUIContent("Instant Preview"), false, InstantPreview, p_node); var controller = DashEditorCore.EditorConfig.editingController; if (p_node is InputNode && controller != null) { InputNode node = p_node as InputNode; menu.AddSeparator(""); if (!controller.autoStart || controller.autoStartInput != node.Model.inputName) { menu.AddItem(new GUIContent("Set as Start Input"), false, SetAsStartInput, p_node); } else { menu.AddItem(new GUIContent("Remove as Start Input"), false, RemoveAsStartInput, p_node); } if (!controller.autoOnEnable || controller.autoOnEnableInput != node.Model.inputName) { menu.AddItem(new GUIContent("Set as OnEnable Input"), false, SetAsOnEnableInput, p_node); } else { menu.AddItem(new GUIContent("Remove as OnEnable Input"), false, RemoveAsOnEnableInput, p_node); } } } menu.AddSeparator(""); if (!SelectionManager.selectedNodes.Contains(Graph.Nodes.IndexOf(p_node))) { menu.AddItem(new GUIContent("Connect Selection as Output"), false, ConnectSelectionAsOutput, p_node); menu.AddItem(new GUIContent("Connect Selection as Input"), false, ConnectSelectionAsInput, p_node); } ((INodeAccess)p_node).GetCustomContextMenu(ref menu); //menu.ShowAsEditorMenu(); GenericMenuPopup.Show(menu, "", Event.current.mousePosition, 240, 300, false, false); }