Esempio n. 1
0
        public Model.ConnectionPointData FindConnectionPointByPosition(Vector2 globalPos)
        {
            foreach (var point in m_data.InputPoints)
            {
                //if (!IsValidInputConnectionPoint(point))
                //{
                //    continue;
                //}

                var gregion = ConnectionPointDataUtility.GetGlobalPointRegion(point.IsInput, point.Region, this);
                if (point.GetGlobalRegion(this.Region).Contains(globalPos) ||
                    gregion.Contains(globalPos))
                {
                    return(point);
                }
            }

            foreach (var point in m_data.OutputPoints)
            {
                var gregion = ConnectionPointDataUtility.GetGlobalPointRegion(point.IsInput, point.Region, this);
                if (point.GetGlobalRegion(this.Region).Contains(globalPos) ||
                    gregion.Contains(globalPos))
                {
                    return(point);
                }
            }

            return(null);
        }
Esempio n. 2
0
        public void DrawConnectionInputPointMark(NodeEvent eventSource, bool justConnecting)
        {
            var defaultPointTex = NodeGUIUtility.pointMark;
            var lastColor       = GUI.color;

            bool shouldDrawEnable = eventSource == null || eventSource.eventSourceNode != null;

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

            foreach (var point in m_data.InputPoints)
            {
                if (shouldDrawWithEnabledColor && Controller.GetConnectType(eventSource.point, point) != null)
                {
                    GUI.color = NGEditorSettings.GUI.COLOR_CAN_CONNECT;
                }
                else
                {
                    GUI.color = (justConnecting) ? NGEditorSettings.GUI.COLOR_CAN_NOT_CONNECT : NGEditorSettings.GUI.COLOR_CONNECTED;
                }
                var rect = ConnectionPointDataUtility.GetGlobalPointRegion(point.IsInput, point.Region, this);
                GUI.DrawTexture(rect, defaultPointTex);
                GUI.color = lastColor;
            }
        }
Esempio n. 3
0
 public bool Conitains(Vector2 globalPos)
 {
     if (m_baseRect.Contains(globalPos))
     {
         return(true);
     }
     foreach (var point in m_data.OutputPoints)
     {
         var rect = ConnectionPointDataUtility.GetGlobalPointRegion(point.IsInput, point.Region, this);
         if (rect.Contains(globalPos))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 4
0
        private void RefreshConnectionPos(float yOffset)
        {
            for (int i = 0; i < m_data.InputPoints.Count; i++)
            {
                var point = m_data.InputPoints[i];
                point.Region = ConnectionPointDataUtility.UpdateRegion(this, point.IsInput, yOffset, i, m_data.InputPoints.Count);
                //point.UpdateRegion(this, yOffset, i, m_data.InputPoints.Count);
            }

            for (int i = 0; i < m_data.OutputPoints.Count; i++)
            {
                var point = m_data.OutputPoints[i];
                point.Region = ConnectionPointDataUtility.UpdateRegion(this, point.IsInput, yOffset, i, m_data.OutputPoints.Count);
                //point.UpdateRegion(this, yOffset, i, m_data.OutputPoints.Count);
            }
        }
Esempio n. 5
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;

            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 = ConnectionPointDataUtility.GetGlobalPointRegion(point.IsInput, point.Region, this);
                //var pointRegion = point.GetGlobalPointRegion(this);

                if (shouldDrawWithEnabledColor && Controller.GetConnectType(eventSource.point, point) != null)
                {
                    GUI.color = NGEditorSettings.GUI.COLOR_CAN_CONNECT;
                }
                else
                {
                    GUI.color = (justConnecting) ? NGEditorSettings.GUI.COLOR_CAN_NOT_CONNECT : NGEditorSettings.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));
                    }
                }
            }
        }