private void DrawOptions(Rect rect) { EditorGUILayout.BeginHorizontal(); // Add Menu if (GUILayout.Button(StratusGUIStyles.addIcon, StratusGUIStyles.smallLayout)) { var menu = new GenericMenu(); menu.AddPopup("Add Trigger", triggerTypes.displayedOptions, (int index) => { target.gameObject.AddComponent(triggerTypes.AtIndex(index)); UpdateConnections(); }); menu.AddPopup("Add Triggerable", triggerableTypes.displayedOptions, (int index) => { target.gameObject.AddComponent(triggerableTypes.AtIndex(index)); UpdateConnections(); }); menu.ShowAsContext(); } //if (GUILayout.Button(new GUIContent($"{messages.Count}", StratusGUIStyles.messageTexture), StratusGUIStyles.smallLayout)) //{ //} // Validation if (GUILayout.Button(StratusGUIStyles.validateIcon, StratusGUIStyles.smallLayout)) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Validate All"), false, () => Validate(ValidateAll)); menu.AddItem(new GUIContent("Validate Trigger Persistence"), false, () => Validate(ValidatePersistence)); menu.AddItem(new GUIContent("Validate Connections"), false, () => Validate(ValidateConnections)); menu.AddItem(new GUIContent("Validate Null"), false, () => Validate(ValidateNull)); menu.ShowAsContext(); } // Options Menu if (GUILayout.Button(StratusGUIStyles.optionsIcon, StratusGUIStyles.smallLayout)) { var menu = new GenericMenu(); menu.AddEnumToggle <StratusTriggerSystem.ConnectionDisplay>(propertyMap[nameof(StratusTriggerSystem.connectionDisplay)]); menu.AddBooleanToggle(propertyMap[nameof(StratusTriggerSystem.showDescriptions)]); menu.AddBooleanToggle(propertyMap[nameof(StratusTriggerSystem.outlines)]); menu.ShowAsContext(); } EditorGUILayout.EndHorizontal(); }
protected override void OnContextMenu(GenericMenu menu) { // Composite menu.AddPopup("Add/Composites", StratusBehaviorTreeEditorWindow.compositeTypes.displayedOptions, (int index) => { this.window.AddChildNode(StratusBehaviorTreeEditorWindow.compositeTypes.AtIndex(index)); }); // Actions menu.AddPopup("Add/Tasks", StratusBehaviorTreeEditorWindow.taskTypes.displayedOptions, (int index) => { this.window.AddChildNode(StratusBehaviorTreeEditorWindow.taskTypes.AtIndex(index)); }); menu.AddItem("Clear", false, () => this.window.RemoveAllNodes()); }
protected override void OnItemContextMenu(GenericMenu menu, BehaviorTree.BehaviorNode treeElement) { // Tasks if (treeElement.data is StratusAITask) { BehaviorTree.BehaviorNode parent = treeElement.GetParent <BehaviorTree.BehaviorNode>(); menu.AddItem("Duplicate", false, () => this.window.AddNode((StratusAIBehavior)treeElement.data.Clone(), parent)); menu.AddPopup("Add/Decorator", StratusBehaviorTreeEditorWindow.decoratorTypes.displayedOptions, (int index) => { this.window.AddParentNode(StratusBehaviorTreeEditorWindow.decoratorTypes.AtIndex(index), treeElement); }); } // Composites else if (treeElement.data is StratusAIComposite) { menu.AddPopup("Add/Tasks", StratusBehaviorTreeEditorWindow.taskTypes.displayedOptions, (int index) => { this.window.AddChildNode(StratusBehaviorTreeEditorWindow.taskTypes.AtIndex(index), treeElement); }); menu.AddPopup("Add/Composites", StratusBehaviorTreeEditorWindow.compositeTypes.displayedOptions, (int index) => { this.window.AddChildNode(StratusBehaviorTreeEditorWindow.compositeTypes.AtIndex(index), treeElement); }); menu.AddPopup("Add/Decorator", StratusBehaviorTreeEditorWindow.decoratorTypes.displayedOptions, (int index) => { this.window.AddParentNode(StratusBehaviorTreeEditorWindow.decoratorTypes.AtIndex(index), treeElement); }); menu.AddPopup("Replace", StratusBehaviorTreeEditorWindow.compositeTypes.displayedOptions, (int index) => { this.window.ReplaceNode(treeElement, StratusBehaviorTreeEditorWindow.compositeTypes.AtIndex(index)); }); } // Decorators else if (treeElement.data is StratusAIDecorator) { if (!treeElement.hasChildren) { menu.AddPopup("Add/Tasks", StratusBehaviorTreeEditorWindow.taskTypes.displayedOptions, (int index) => { this.window.AddChildNode(StratusBehaviorTreeEditorWindow.taskTypes.AtIndex(index), treeElement); }); menu.AddPopup("Add/Composites", StratusBehaviorTreeEditorWindow.compositeTypes.displayedOptions, (int index) => { this.window.AddChildNode(StratusBehaviorTreeEditorWindow.compositeTypes.AtIndex(index), treeElement); }); } } // Common if (treeElement.hasChildren) { menu.AddItem("Remove/Include Children", false, () => this.window.RemoveNode(treeElement)); menu.AddItem("Remove/Exclude Children", false, () => this.window.RemoveNodeOnly(treeElement)); } else { menu.AddItem("Remove", false, () => this.window.RemoveNode(treeElement)); } }