Beispiel #1
0
        public void DrawConnectionInputPointMark(NodeEvent eventSource, bool justConnecting)
        {
            var defaultPointTex = NodeGUIUtility.pointMark;
            var lastColor       = GUI.color;

            bool shouldDrawEnable =
                !(eventSource != null && eventSource.eventSourceNode != null &&
                  !Model.ConnectionData.CanConnect(eventSource.eventSourceNode.Data, m_data)
                  );

            bool shouldDrawWithEnabledColor =
                shouldDrawEnable && justConnecting &&
                eventSource != null &&
                eventSource.eventSourceNode.Id != this.Id &&
                eventSource.point.IsOutput;

            foreach (var point in m_data.InputPoints)
            {
                if (IsValidInputConnectionPoint(point))
                {
                    if (shouldDrawWithEnabledColor)
                    {
                        GUI.color = Model.Settings.GUI.COLOR_CAN_CONNECT;
                    }
                    else
                    {
                        GUI.color = (justConnecting) ? Model.Settings.GUI.COLOR_CAN_NOT_CONNECT : Model.Settings.GUI.COLOR_CONNECTED;
                    }

                    GUI.DrawTexture(point.GetGlobalPointRegion(this), defaultPointTex);
                    GUI.color = lastColor;
                }
            }
        }
Beispiel #2
0
        public void DrawConnectionOutputPointMark(NodeEvent eventSource, bool justConnecting, Event current)
        {
            var defaultPointTex = NodeGUIUtility.pointMark;
            var lastColor       = GUI.color;

            bool shouldDrawEnable =
                !(eventSource != null && eventSource.eventSourceNode != null &&
                  !Model.ConnectionData.CanConnect(m_data, eventSource.eventSourceNode.Data)
                  );

            bool shouldDrawWithEnabledColor =
                shouldDrawEnable && justConnecting &&
                eventSource != null &&
                eventSource.eventSourceNode.Id != this.Id &&
                eventSource.point.IsInput;

            var globalMousePosition = current.mousePosition;

            foreach (var point in m_data.OutputPoints)
            {
                var pointRegion = point.GetGlobalPointRegion(this);

                if (shouldDrawWithEnabledColor)
                {
                    GUI.color = Model.Settings.GUI.COLOR_CAN_CONNECT;
                }
                else
                {
                    GUI.color = (justConnecting) ? Model.Settings.GUI.COLOR_CAN_NOT_CONNECT : Model.Settings.GUI.COLOR_CONNECTED;
                }
                GUI.DrawTexture(
                    pointRegion,
                    defaultPointTex
                    );
                GUI.color = lastColor;

                // eventPosition is contained by outputPointRect.
                if (pointRegion.Contains(globalMousePosition))
                {
                    if (current.type == EventType.MouseDown)
                    {
                        NodeGUIUtility.NodeEventHandler(
                            new NodeEvent(NodeEvent.EventType.EVENT_CONNECTING_BEGIN, this, current.mousePosition, point));
                    }
                }
            }
        }