Exemple #1
0
 /// <summary>
 /// Tests the node whether the specified position is inside any of the node's elements and returns a potentially focused connection knob.
 /// </summary>
 public bool ClickTest(Vector2 position, out ConnectionKnob focusedKnob)
 {
     focusedKnob = null;
     if (rect.Contains(position))
     {
         return(true);
     }
     for (int i = 0; i < connectionKnobs.Count; i++)
     {             // Check if any nodeKnob is focused instead
         if (connectionKnobs[i].GetCanvasSpaceKnob().Contains(position))
         {
             focusedKnob = connectionKnobs[i];
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// Draws the connection curves from this knob to all it's connections
        /// </summary>
        public override void DrawConnections()
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            Vector2 startPos = GetGUIKnob().center;
            Vector2 startDir = GetDirection();

            for (int i = 0; i < connections.Count; i++)
            {
                ConnectionKnob conKnob = connections[i];
                Vector2        endPos  = conKnob.GetGUIKnob().center;
                Vector2        endDir  = conKnob.GetDirection();
                NodeEditorGUI.DrawConnection(startPos, startDir, endPos, endDir, color);
            }
        }
Exemple #3
0
 /// <summary>
 /// Tests the node whether the specified position is inside any of the node's elements and returns a potentially focused connection knob.
 /// </summary>
 public bool ClickTest(Vector2 position, out ConnectionKnob focusedKnob)
 {
     focusedKnob = null;
     if (rect.Contains(position))
     {
         return(true);
     }
     foreach (ConnectionKnob knob in connectionKnobs)
     {             // Check if any nodeKnob is focused instead
         if (knob.GetCanvasSpaceKnob().Contains(position))
         {
             focusedKnob = knob;
             return(true);
         }
     }
     return(false);
 }
Exemple #4
0
        /// <summary>
        /// Tests the node whether the specified position is inside any of the node's elements and returns a potentially focused connection knob.
        /// </summary>
        public bool ClickTest(Vector2 position, out ConnectionKnob focusedKnob)
        {
            focusedKnob = null;
            if (rect.Contains(position))
            {
                return(true);
            }
            Vector2 dist = position - rect.center;

            if (Math.Abs(dist.x) > size.x || Math.Abs(dist.y) > size.y)
            {
                return(false);                // Quick check if pos is within double the size
            }
            for (int i = 0; i < connectionKnobs.Count; i++)
            {             // Check if any nodeKnob is focused instead
                if (connectionKnobs[i].GetCanvasSpaceKnob().Contains(position))
                {
                    focusedKnob = connectionKnobs[i];
                    return(true);
                }
            }
            return(false);
        }
Exemple #5
0
        /// <summary>
        /// Returns the node at the specified canvas-space position in the specified editor and returns a possible focused knob aswell
        /// </summary>
        public static Node NodeAtPosition(NodeEditorState editorState, Vector2 canvasPos, out ConnectionKnob focusedKnob)
        {
            focusedKnob = null;
            if (editorState == null || NodeEditorInputSystem.shouldIgnoreInput(editorState))
            {
                return(null);
            }
            NodeCanvas canvas = editorState.canvas;

            for (int nodeCnt = canvas.nodes.Count - 1; nodeCnt >= 0; nodeCnt--)
            {             // Check from top to bottom because of the render order
                Node node = canvas.nodes [nodeCnt];
                if (node.ClickTest(canvasPos, out focusedKnob))
                {
                    return(node);                    // Node is clicked on
                }
            }
            return(null);
        }
Exemple #6
0
 /// <summary>
 /// Returns the node at the specified canvas-space position in the current editor and returns a possible focused knob aswell
 /// </summary>
 public static Node NodeAtPosition(Vector2 canvasPos, out ConnectionKnob focusedKnob)
 {
     return(NodeAtPosition(curEditorState, canvasPos, out focusedKnob));
 }