protected void UpdateNodeMove() { if (GUIHelper.ReleasedLMB() && _movingNode) { _movingNode = false; Event.current.Use(); } var isHover = isHovering(); bool isDragging = _movingNode && (Event.current.type == EventType.MouseDrag); if (isDragging) { SetPos(_rect.x + Event.current.delta.x, _rect.y + Event.current.delta.y); Event.current.Use(); } if (GUIHelper.PressedLMB() && isHover) { _movingNode = true; _window.nodeArea.selectingNode = this; Event.current.Use(); } }
public void Draw() { ZoomHelper.Begin(_zoom, _screenRect, _offset); { foreach (var node in _nodes) { node.Draw(); } UpdateCameraMove(); } if (GUIHelper.ReleasedLMB()) { Connector.connectingSource = null; } if (Connector.connectingSource != null) { GUIHelper.DrawLine(Connector.connectingSource.rect.center, Event.current.mousePosition, Color.blue); } ZoomHelper.End(_zoom); UpdateCameraZoom(); UpdateCreate(); }
public void Draw() { var orgColor = GUI.color; if (connectingSource == this) { GUI.color = Color.blue; } else if (isHovering() && CanConnectToSource()) { GUI.color = Color.blue; } else { GUI.color = Color.white; } GUI.DrawTexture(_rect, EditorGUIUtility.whiteTexture); if (type == ConnectorType.Output) { var nodeArea = _window.nodeArea; foreach (var connectorPair in _data.connectorPairList) { var linkToConnector = nodeArea.GetNode(connectorPair.nodeId).GetConnector(connectorPair.connectorId); GUIHelper.DrawLine(this._rect.center, linkToConnector.rect.center, Color.white); } } GUI.color = orgColor; if (isPressed()) { Event.current.Use(); if (connectingSource == null) { connectingSource = this; } } if (GUIHelper.ReleasedLMB()) { if (CanConnectToSource()) { AddConnector(connectingSource); connectingSource.AddConnector(this); connectingSource = null; Event.current.Use(); } } }
private bool isReleased() { return(isHovering() && GUIHelper.ReleasedLMB()); }