BlueGraph icon indicating copy to clipboard operation
BlueGraph copied to clipboard

Open Graph Instance at runtime

Open neoneper opened this issue 4 years ago • 1 comments

I am instantiating a graph at runtime and I would like to know how I could go about opening the graph window for this instance.

neoneper avatar Oct 02 '20 14:10 neoneper

Something like this? Specifically the CreateWindow and Load calls

using BlueGraph.Editor;
using BlueGraphSamples;
using UnityEditor;
using UnityEngine;

public class MakeDynamicGraph : MonoBehaviour
{
    MonoBehaviourGraph graph;

    void Update()
    {
        if (Input.GetKeyUp(KeyCode.Space))
        {
            // Make sure references to editor scripts are stripped
            // while compiling a real build.
            #if UNITY_EDITOR

            if (!graph)
            {
                graph = ScriptableObject.CreateInstance<MonoBehaviourGraph>();
            }

            var editor = EditorWindow.CreateWindow<GraphEditorWindow>();
            editor.Load(graph);

            #endif
        }
    }
}

McManning avatar Oct 26 '20 01:10 McManning