public GraphView(GraphViewWindow window, Graph graph) { Graph = graph; _window = window; _nodeProvider = ScriptableObject.CreateInstance <GraphViewNodeProvider>(); _nodeConnector = new GraphViewConnector(_nodeProvider); _inputs = this.Query <GraphViewInputPort>().Build(); _outputs = this.Query <GraphViewOutputPort>().Build(); AddToClassList(UssClassName); SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); SetupNodeProvider(); SetupNodes(); SetupConnections(); RegisterCallback <KeyDownEvent>(OnKeyDown); RegisterCallback <GeometryChangedEvent>(evt => ShowAll()); // Use this event because the layout isn't build right away so ShowAll won't work immediately nodeCreationRequest = OnShowCreateNode; graphViewChanged = OnGraphChanged; canPasteSerializedData = data => canPaste; serializeGraphElements = OnCopy; unserializeAndPaste = OnPaste; this.AddManipulator(new ContentDragger()); this.AddManipulator(new SelectionDragger()); this.AddManipulator(new RectangleSelector()); this.AddManipulator(new ClickSelector()); Undo.undoRedoPerformed += Rebuild; EditorApplication.playModeStateChanged += PlayStateChanged; if (Application.isPlaying) // Make sure the callback still gets set if the window was opened during play mode { PlayStateChanged(PlayModeStateChange.EnteredPlayMode); FrameChanged(null); } }
public GraphViewConnector(GraphViewNodeProvider provider) { _provider = provider; _graphViewChange.edgesToCreate = new List <Edge>(); _graphViewChange.elementsToRemove = new List <GraphElement>(); }