Beispiel #1
0
//	private Vector2 fullOffset = Vector2.zero;
    private void NodeDragging(int i)
    {
        #region Dragging

        if (Event.current.button == 0 && Event.current.type == EventType.MouseDrag && nodes[i].pos.Contains(Event.current.mousePosition) && dragginNode == false)
        {
            dragginNode    = true;
            gettingDragged = nodes[i];
            brokeOutOfZone = false;
            dragPointStart = Event.current.mousePosition;

            if (Event.current.alt)
            {
                gettingDragged.SetOffsets(gettingDragged);
            }
        }

        if (draggingThisFrame && dragginNode && gettingDragged.canDrag && brokeOutOfZone || draggingThisFrame && dragginNode && gettingDragged.canDrag && Vector2.Distance(dragPointStart, Event.current.mousePosition) > 7)
        {
            gettingDragged.realPos.position = Vector2.Lerp(gettingDragged.pos.position, (draggingVector - gettingDragged.pos.size / 2) - offset, 5);
            gettingDragged.gettingDragged   = true;
            brokeOutOfZone = true;

            if (Event.current.alt)
            {
                gettingDragged.ConnectionRealPosInc(gettingDragged, true);
            }
        }



        if (dropped)
        {
            dragginNode    = false;
            brokeOutOfZone = true;
            gettingDragged.gettingDragged = false;
            didClickThisEventTime         = false;
            //fullOffset = Vector2.zero;
        }

        #endregion

        #region Inspector

        if (clickedThisFrame && !constantInspectorRect.Contains(Event.current.mousePosition) && Event.current.alt == true)
        {
            if (clickedRect(nodes [i].pos))
            {
                propertiesTab         = false;
                currentlySelected     = nodes[i];
                drawInspector         = true;
                selectedNode          = true;
                didClickThisEventTime = true;
            }
            else
            {
                if (!didClickThisEventTime)
                {
                    drawInspector = false;
                    selectedNode  = false;
                }
            }
        }

        #endregion

        #region Deleting and Folding

        //Deleting
        if (Event.current.button == 0 && Event.current.type == EventType.MouseDown && nodes[i].pos.Contains(Event.current.mousePosition) && dragginNode == false && Event.current.shift == true)
        {
            connections.RemoveValue(nodes[i].nodeID);
            nodes.RemoveAt(i);
        }

        if (Event.current.button == 2 && Event.current.type == EventType.MouseDown && Event.current.shift == true)
        {
            if (nodes [i].inp.Contains(Event.current.mousePosition))
            {
                for (int x = 0; x < nodes.Count; x++)
                {
                    if (nodes[x].connectedIDS.Contains(nodes[i].nodeID))
                    {
                        nodes[x].displayConnections.Remove(nodes[i]);
                        nodes[x].connectedIDS.Remove(nodes[i].nodeID);
                    }
                }
            }
        }

        if (Event.current.button == 2 && Event.current.type == EventType.MouseDown && Event.current.shift == true)
        {
            if (nodes [i].outp.Contains(Event.current.mousePosition))
            {
                if (nodes[i].foldedChildren)
                {
                    nodes[i].MainUnFoldChild();
                }
                else if (!nodes[i].foldedChildren)
                {
                    nodes[i].MainFoldChild(nodes[i].pos.position);
                }
            }
        }


        #endregion
    }