public void Draw(NodeView[] nodes, LinkData[] links, Vector2 selectionOffset, Rect window) { var current = Event.current; var hoverPosition = current.mousePosition + selectionOffset; var viewport = GUILayoutUtility.GetLastRect(); DragSelection(); if (!current.IsLayout()) { offset = viewport.position; } UpdateKeyDown(); //Special handling for single node. This is to make GUI.DragWindow work correctly if (SelectedNodes.Count == 1 && DragSize == Vector2.zero) { if (!current.IsUsed() && !current.IsLayoutOrRepaint()) { UnselectAll(); SelectNode(nodes, hoverPosition); GUI.RequestRepaint(); } return; } //Deselect all if (current.MouseButtonDown(1) && current.isMouse) { UnselectAll(); GUI.RequestRepaint(); } if (current.mousePosition.x + window.x < window.width && current.mousePosition.y - window.y < window.height) { UpdateSelectionArea(selectionOffset, Event.current, nodes); } else { DragSize = Vector2.zero; StartMousePosition = Vector2.zero; DragSize = Vector2.zero; } //Mouse over if (DragSize == Vector2.zero && !current.IsUsed() && !current.MouseDrag()) { if (SelectedNodes.Count <= 1) { UnselectAll(); var selection = SelectNode(nodes, hoverPosition); if (selection != null) { SelectNode(selection); } } } }
public void Draw(NodeView[] nodes, LinkData[] links, Vector2 selectionOffset) { var e = Event.current; var Selection = Rect.zero; var SelectionDisplay = Rect.zero; if (e.keyCode == KeyCode.Delete) { DestroySelection(); } DragSelection(); SelectionDisplay = new Rect(StartMousePosition.x, StartMousePosition.y, DragSize.x, DragSize.y); Selection = new Rect(StartMousePosition.x + selectionOffset.x, StartMousePosition.y + selectionOffset.y, DragSize.x, DragSize.y); if (e.button == 1 && e.isMouse && (e.type == EventType.MouseDown)) { UnselectAll(); GUI.RequestRepaint(); } if (e.button == 0 && e.isMouse && (e.type == EventType.MouseDown)) { UnselectAll(); StartMousePosition = e.mousePosition; GUI.RequestRepaint(); } else if (e.type == EventType.MouseDrag && Selection.x != 0 && Selection.y != 0) { DragSize = e.mousePosition - StartMousePosition; UnselectAll(); GUI.RequestRepaint(); } else if (Selection.x != 0 && Selection.y != 0 && Selection.width != 0 && Selection.height != 0) { if (e.type == EventType.MouseUp) { SelectNodes(nodes, Selection); StartMousePosition = Vector2.zero; DragSize = Vector2.zero; SelectionDisplay = Rect.zero; GUI.RequestRepaint(); } } if (SelectionDisplay.width != 0 && SelectionDisplay.height != 0) { UnityEngine.GUI.Label(SelectionDisplay, "", UnityEngine.GUI.skin.GetStyle("grey_border")); } }
public void DrawEditorNodes(Vector2 editorScrollPos) { farNodeX = 0; farNodeY = 0; editorWindow.BeginWindows(); var i = 0; if (Nodes == null) { return; } if (Event.current.button == 2) { editorScrollPos -= Event.current.delta * 0.5f; GUI.RequestRepaint(); } foreach (NodeView node in Nodes) { if (node == null) { return; } node.DrawWindow(i, DrawNodeWindow, false); i++; farNodeX = Mathf.Max(node.GetRect().x, farNodeX); farNodeY = Mathf.Max(node.GetRect().y, farNodeY); } editorWindow.EndWindows(); }
public void CreateLink(InputData _input, OutputData _output) { if (isInstance) { constellationScript.IsDifferentThanSource = true; } selectedInput = null; selectedOutput = null; var newLink = new LinkData(_input, _output); if (constellationScript.IsLinkValid(newLink)) { constellationScript.AddLink(newLink); OnLinkAdded(newLink); undoable.AddAction(); GUI.RequestRepaint(); } }
private void DrawIncompleteLink() { if (selectedInput != null || selectedOutput != null) { var e = Event.current; if (selectedInput != null) { LinksView.DrawNodeCurve(new Rect(e.mousePosition.x, e.mousePosition.y, 0, 0), LinksView.InputPosition(selectedInput)); GUI.RequestRepaint(); } else if (selectedOutput != null) { LinksView.DrawNodeCurve(LinksView.OutputPosition(selectedOutput), new Rect(e.mousePosition.x, e.mousePosition.y, 0, 0)); GUI.RequestRepaint(); } if (e.button == 1) { selectedInput = null; selectedOutput = null; } } }
public void RequestRepaint() { GUI.RequestRepaint(); }