Пример #1
0
        public Vector2 GlobalConnectionPointPosition(ConnectionPoint p)
        {
            var x = baseRect.x + p.buttonRect.x;

            if (p.isInput)
            {
                x = baseRect.x + p.buttonRect.x;
            }
            if (p.isOutput)
            {
                x = baseRect.x + p.buttonRect.x + NodeEditorSetting.POINT_SIZE;
            }

            var y = baseRect.y + p.buttonRect.y + NodeEditorSetting.POINT_SIZE / 2;

            return(new Vector2(x, y));
        }
Пример #2
0
 protected void OnClickOutPoint(ConnectionPoint outPoint)
 {
     selectedOutPoint = outPoint;
     if (selectedInPoint != null)
     {
         // filt loop
         if (Node.LoopCheck(selectedOutPoint.node, selectedInPoint.node) && selectedInPoint.ValidateConnectPoint(outPoint) && selectedOutPoint.ValidateConnectPoint(selectedInPoint))
         {
             CreateConnection();
             ClearConnectionSelection();
         }
         else
         {
             ClearConnectionSelection();
         }
     }
 }
Пример #3
0
        protected void DrawConnectionLine(Event e)
        {
            if (selectedInPoint != null && selectedOutPoint == null)
            {
                Handles.DrawBezier(
                    selectedInPoint.rect.center,
                    e.mousePosition,
                    selectedInPoint.rect.center + Vector2.left * 50f,
                    e.mousePosition - Vector2.left * 50,
                    Color.white,
                    null,
                    5f);

                GUI.changed = true;
            }

            if (selectedOutPoint != null && selectedInPoint == null)
            {
                Handles.DrawBezier(
                    selectedOutPoint.rect.center,
                    e.mousePosition,
                    selectedOutPoint.rect.center - Vector2.left * 50f,
                    e.mousePosition + Vector2.left * 50f,
                    Color.white,
                    null,
                    5f);

                GUI.changed = true;
            }


            if (e.keyCode == KeyCode.Escape)
            {
                selectedOutPoint = null;
                selectedInPoint  = null;
            }
            if (e.isMouse && e.button == 0)
            {
                if (selectedOutPoint != null && selectedInPoint == null && !selectedOutPoint.rect.Contains(e.mousePosition) ||
                    selectedInPoint != null && selectedOutPoint == null && !selectedInPoint.rect.Contains(e.mousePosition))
                {
                    selectedOutPoint = null;
                    selectedInPoint  = null;
                }
            }
        }
        public void OnClickOutPoint(ConnectionPoint outPoint)
        {
            _selectedOutPoint = outPoint;

            if (_selectedInPoint != null)
            {
                if (_selectedOutPoint.Node != _selectedInPoint.Node)
                {
                    // clear previous connection to this out point
                    RemoveConnection(_selectedOutPoint);

                    CreateConnection(_selectedInPoint, _selectedOutPoint);
                    ClearConnectionSelection();
                }
                else
                {
                    ClearConnectionSelection();
                }
            }
        }
Пример #5
0
 public void RemoveConnectionPoint(ConnectionPoint connectionPoint)
 {
     OutPoints.Remove(connectionPoint);
 }
 private void ClearConnectionSelection()
 {
     _selectedInPoint  = null;
     _selectedOutPoint = null;
 }
 private void DrawConnection(ConnectionPoint fromPoint, ConnectionPoint toPoint)
 {
     DrawConnection(fromPoint.Rect.center, toPoint.Rect.center);
 }
Пример #8
0
 public Connection(ConnectionPoint inPoint, ConnectionPoint outPoint)
 {
     this.inPoint  = inPoint;
     this.outPoint = outPoint;
 }
Пример #9
0
 public static bool ContainsConnection(this List <Connection> connections, Node start, ConnectionPoint output, Node end, ConnectionPoint input)
 {
     foreach (var con in connections)
     {
         if (con.IsSameDetail(start, output, end, input))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #10
0
 public bool IsEndAtConnectionPoint(ConnectionPoint p)
 {
     return(inputPoint == p);
 }
Пример #11
0
 public bool IsStartAtConnectionPoint(ConnectionPoint p)
 {
     return(outputPoint == p);
 }
Пример #12
0
        public Connection(string label, Node start, ConnectionPoint output, Node end, ConnectionPoint input)
        {
            this.label        = label;
            this.connectionId = Guid.NewGuid().ToString();

            this.startNode   = start;
            this.outputPoint = output;
            this.endNode     = end;
            this.inputPoint  = input;

            this.startPointInfo = start.nodeNameText + ":" + output.id;
            this.endPointInfo   = end.nodeNameText + ":" + input.id;
        }