UnityEditor.Graphs - No documentation

I’m trying to write an editor window graph GUI, using UnityEditor.Graphs. Unfortunately, there’s no official documentation that I can find, and I only found a single post on StackOverflow here:

My code currently looks like this:

    [MenuItem("Window/Composite Statistics/Actor Wizard")]
    public static void ShowWindow()
    {
        GetWindow<ActorWizard>();
    }

    private void RefreshGraph()
    {
        if (!graph)
        {
            graph = CreateInstance<Graph>();
            // graph.hideFlags = HideFlags.HideAndDontSave;
            graph.Clear();

            Node node = CreateInstance<Node>();
            node.title = _actorName;
            node.position = new Rect(100F, 0F, 200F, 100F);
            node.AddProperty(new Property(typeof(string), "Actor"));

            graph.AddNode(node);
        }

        if (!graphGUI)
            graphGUI = CreateInstance<ActorWizardGraphGUI>();
        // graphGUI.graph = graph;
        // graphGUI.graph = null;
        // graph = null;

        EditorUtility.SetDirty(graphGUI);
    }

    private Graph graph;
    private ActorWizardGraphGUI graphGUI;
    private GameObject _actorGO;
    private Actor _actor = null;
    private string _actorName = "None";
    private Vector2 _scrollPosition;

    void OnGUI()
    {
        // if (!graphGUI)
            RefreshGraph();
        if (graphGUI != null && graphGUI.graph != null)
        {
            graphGUI.BeginGraphGUI(this, new Rect(0F, 0F, position.xMax, position.yMax));
            graphGUI.OnGraphGUI();
            graphGUI.EndGraphGUI();
        }
    }

    private void CheckForActor()
    {
        var tempGO = (GameObject)EditorGUILayout.ObjectField("Actor: ", _actorGO, typeof(GameObject), true);
        if (tempGO != _actorGO)
        {
            if (tempGO)
            {
                var tempActor = tempGO.GetComponent<Actor>();
                if (tempActor)
                {
                    _actorGO = tempGO;
                    _actor = tempActor;
                }
            }
        }
    }

Images of what I’ve managed to get it to do:


2380890--161966--This is wrong, too.jpg

How do I fix this, so that both the grid and the node display properly?

1 Like

There’s a link in that SO thread about writing your own node editor, which is what I would do (and have done) since there’s no documentation on the Graphs namespace

Thank you. I’m not sure how I missed those.

Having explored those links, as far as I can tell none of them use UnityEditor.Graphs. While they do involve creating a graph, my question specifically addresses the classes found in that namespace.

cant imagine there’s anything in the namespace that you cant recreate.
without docs, you’ll just have to test them all using the intellisense hints (sadly, no documentation in there either) unless someone whos used them shows up.

writing your own means you know how it works, and it won’t run on ‘black magic’

Figuring it out without documentation is exactly what I’m doing right now. I’m doing quite well at it, in fact.

However, having taught myself programming for close to two decades, I appreciate the value of good documentation, and tutorials.

1 Like

I am also trying to work myself in this topic. Have you meanwhile found any documentary or do you have any tipps for someone new to graph editors?

1 Like