Beispiel #1
0
        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();
        }
Beispiel #2
0
        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();
                }
            }
        }