private VisualElement CreateToolBar(BehaviorTreeView graphView) { return(new IMGUIContainer( () => { GUILayout.BeginHorizontal(EditorStyles.toolbar); if (!Application.isPlaying) { if (GUILayout.Button("Save", EditorStyles.toolbarButton)) { var guiContent = new GUIContent(); if (graphView.Save()) { guiContent.text = "Successfully updated."; this.ShowNotification(guiContent); } else { guiContent.text = "Invalid tree. one or mode nodes have error."; this.ShowNotification(guiContent); } } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } )); }
private static void StructGraphView(GraphEditorWindow window, BehaviorTree behaviorTree) { window.rootVisualElement.Clear(); var graphView = new BehaviorTreeView(behaviorTree, window); graphView.Restore(); window.rootVisualElement.Add(window.CreateToolBar(graphView)); window.rootVisualElement.Add(graphView); }