BlueGraph
BlueGraph copied to clipboard
Open Graph Instance at runtime
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.
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
}
}
}