//This is called outside Begin/End Windows from GraphEditor.
        public static void ShowToolbar(Graph graph)
        {
            // var owner = graph.agent != null && graph.agent is GraphOwner && ( graph.agent as GraphOwner ).graph == graph ? (GraphOwner)graph.agent : null;
            var owner = graph.agent as GraphOwner;

            GUILayout.BeginHorizontal(EditorStyles.toolbar);

            ///----------------------------------------------------------------------------------------------
            ///Left side
            ///----------------------------------------------------------------------------------------------

            GUILayout.Space(4);

            if (GUILayout.Button("File", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                GetToolbarMenu_File(graph, owner).ShowAsContext();
            }

            if (GUILayout.Button("Edit", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                GetToolbarMenu_Edit(graph, owner).ShowAsContext();
            }

            if (GUILayout.Button("Prefs", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                GetToolbarMenu_Prefs(graph, owner).ShowAsContext();
            }

            GUILayout.Space(10);

            if (owner != null && GUILayout.Button("Select Owner", EditorStyles.toolbarButton))
            {
                Selection.activeObject = owner;
                EditorGUIUtility.PingObject(owner);
            }

            if (EditorUtility.IsPersistent(graph) && GUILayout.Button("Select Graph", EditorStyles.toolbarButton))
            {
                Selection.activeObject = graph;
                EditorGUIUtility.PingObject(graph);
            }

            GUILayout.Space(10);

            EditorGUIUtility.SetIconSize(new Vector2(15, 15));
            if (GUILayout.Button(new GUIContent(StyleSheet.log, "Open Graph Console"), EditorStyles.toolbarButton))
            {
                GraphConsole.ShowWindow();
            }

            if (GUILayout.Button(new GUIContent(StyleSheet.lens, "Open Graph Explorer"), EditorStyles.toolbarButton))
            {
                GraphExplorer.ShowWindow();
            }

            if (GUILayout.Button(new GUIContent(StyleSheet.refactor, "Open Graph Refactor"), EditorStyles.toolbarButton))
            {
                GraphRefactor.ShowWindow();
            }
            EditorGUIUtility.SetIconSize(Vector2.zero);

            GUILayout.Space(10);

            ///----------------------------------------------------------------------------------------------

            graph.CallbackOnGraphEditorToolbar();

            ///----------------------------------------------------------------------------------------------
            ///Mid
            ///----------------------------------------------------------------------------------------------

            GUILayout.Space(10);
            GUILayout.FlexibleSpace();

            //...



            //...

            GUILayout.FlexibleSpace();
            GUILayout.Space(10);

            ///----------------------------------------------------------------------------------------------
            ///Right side
            ///----------------------------------------------------------------------------------------------

            GUI.backgroundColor = Color.clear;
            GUI.color           = new Color(1, 1, 1, 0.3f);
            GUILayout.Label(string.Format("{0} @NodeCanvas Framework v{1}", graph.GetType().Name, NodeCanvas.Framework.Internal.GraphSource.FRAMEWORK_VERSION.ToString("0.00")), EditorStyles.toolbarButton);
            GUILayout.Space(10);
            GUI.color           = Color.white;
            GUI.backgroundColor = Color.white;

            //GRAPHOWNER JUMP SELECTION
            if (owner != null)
            {
                if (GUILayout.Button(string.Format("[{0}]", owner.gameObject.name), EditorStyles.toolbarDropDown, GUILayout.Width(120)))
                {
                    var menu = new GenericMenu();
                    foreach (var _o in Object.FindObjectsOfType <GraphOwner>().OrderBy(x => x.gameObject != owner.gameObject))
                    {
                        var o = _o;
                        menu.AddItem(new GUIContent(o.gameObject.name + "/" + o.GetType().Name), o == owner, () => { SetReferences(o); });
                    }
                    menu.ShowAsContext();
                }
            }

            Prefs.isEditorLocked = GUILayout.Toggle(Prefs.isEditorLocked, "Lock", EditorStyles.toolbarButton);

            GUILayout.Space(4);

            GUILayout.EndHorizontal();
            GUI.backgroundColor = Color.white;
            GUI.color           = Color.white;
        }
Example #2
0
 public static void OpenExplorer()
 {
     GraphExplorer.ShowWindow();
 }