Assets/xNode/Scripts/Editor/NodeEditorAction.cs
/// <summary> Draw a connection as we are dragging it </summary>
Draw a connection as we are dragging it
Draw a connection as we are dragging it
public void DrawDraggedConnection() {
            if (IsDraggingPort) {
                Color col = NodeEditorPreferences.GetTypeColor(draggedPort.ValueType);
                col.a = draggedPortTarget != null ? 1.0f : 0.6f;
                Rect fromRect;
                if (!_portConnectionPoints.TryGetValue(draggedPort, out fromRect)) return;
                List<Vector2> gridPoints = new List<Vector2>();
                gridPoints.Add(fromRect.center);
                for (int i = 0; i < draggedOutputReroutes.Count; i++) {
                    gridPoints.Add(draggedOutputReroutes[i]);
                }
                if (draggedPortTarget != null) gridPoints.Add(portConnectionPoints[draggedPortTarget].center);
                else gridPoints.Add(WindowToGridPosition(Event.current.mousePosition));
                if(draggedPort.IsInput)
                {
                    gridPoints.Reverse();
                }
                DrawNoodle(col, gridPoints);
                Color bgcol = Color.black;
                Color frcol = col;
                bgcol.a = 0.6f;
                frcol.a = 0.6f;
                for (int i = 0; i < draggedOutputReroutes.Count; i++) {
                    Rect rect = new Rect(draggedOutputReroutes[i], new Vector2(16, 16));
                    rect.position = new Vector2(rect.position.x - 8, rect.position.y - 8);
                    rect = GridToWindowRect(rect);
                    NodeEditorGUILayout.DrawPortHandle(rect, bgcol, frcol);
                }
            }
        }
public void DrawDraggedConnection ( ) { if ( IsDraggingPort ) { Color col = NodeEditorPreferences . GetTypeColor ( draggedPort . ValueType ) ; col . a = draggedPortTarget != null ? 1.0f : 0.6f ; Rect fromRect ; if ( ! _portConnectionPoints . TryGetValue ( draggedPort , out fromRect ) ) return ; List < Vector2 > gridPoints = new List < Vector2 > ( ) ; gridPoints . Add ( fromRect . center ) ; for ( int i = 0 ; i < draggedOutputReroutes . Count ; i ++ ) { gridPoints . Add ( draggedOutputReroutes [ i ] ) ; } if ( draggedPortTarget != null ) gridPoints . Add ( portConnectionPoints [ draggedPortTarget ] . center ) ; else gridPoints . Add ( WindowToGridPosition ( Event . current . mousePosition ) ) ; if ( draggedPort . IsInput ) { gridPoints . Reverse ( ) ; } DrawNoodle ( col , gridPoints ) ; Color bgcol = Color . black ; Color frcol = col ; bgcol . a = 0.6f ; frcol . a = 0.6f ; for ( int i = 0 ; i < draggedOutputReroutes . Count ; i ++ ) { Rect rect = new Rect ( draggedOutputReroutes [ i ] , new Vector2 ( 16 , 16 ) ) ; rect . position = new Vector2 ( rect . position . x - 8 , rect . position . y - 8 ) ; rect = GridToWindowRect ( rect ) ; NodeEditorGUILayout . DrawPortHandle ( rect , bgcol , frcol ) ; } } }
Draw a connection as we are dragging it
Draw a connection as we are dragging it
// Loop through reroute points again and draw the points // Draw reroute point at position