//---------------------------------------------------------------------------------------------------------------
    void UpdateControls()
    {
        if(sceneCam == null)
        {
            return;
        }

        //	get groundP
        RaycastHit hit;
        Vector3 p = new Vector3( Event.current.mousePosition.x, sceneWindow.height-Event.current.mousePosition.y, 0);
        if(Physics.Raycast(sceneCam.ScreenPointToRay(p), out hit))
        {
            if(hit.transform.gameObject.layer == LayerMask.NameToLayer("Ground"))
            {
                currGroundP = hit.point + Vector3.up * yOff;
            }
            else
                currGroundP = NULLPOS;
        }
        else
        {
            currGroundP = NULLPOS;
        }

        //	get hover
        connectionOnHover = null;
        if(hit.transform != null && nodes.Exists(x=> x.obj == hit.transform.gameObject))
        {
            EditorNode node = GetNodeByGO(hit.transform.gameObject);
            SetNodeOnHover(node);
            currGroundP = node.position;
        }
        else
        {
            SetNodeOnHover(null);
            foreach(EditorConnection c in edges)
            {
                if(c.forceConnection || c.magnitude <= data.autoConnectionDist)
                {
                    if(c.CheckHover())
                    {
                        connectionOnHover = c;
                        break;
                    }
                }
            }
        }
    }
 void DeleteConnection(EditorConnection c)
 {
     if(c != null)
     {
         edges.Remove(c);
         isDirty = true;
     }
 }
    void onMouseDown(Event e)
    {
        if(e.button == 0)
        {
            if(e.shift)
            {
                if(connectionOnHover != null)
                {
                    connectionOnHover.NextMode();
                    isDirty = true;
                }
            }
            else if(e.control)
            {
                connectMode = true;
            }
            else if(nodeOnHover == null)
            {
                connectionOnHover = null;
                stateChanger.Add(()=> {
                    nodeOnHover = CreateNode(currGroundP);
                });
                e.Use();
            }
        }

        if(nodeOnHover != null)
        {
            nodeOnHandle = nodeOnHover;
        }
    }
    EditorConnection CreateConnection(EditorNode a, EditorNode b, connectDir dir, bool forced)
    {
        if(a != b && a != null && b != null)
        {
            if(areConnected(a, b))
            {
                EditorConnection c = edges.Find(x=> x.containsNodes(a, b));

                if(!c.forceConnection)
                {
                    c.supressConnection = c.magnitude <= data.autoConnectionDist;
                }
                else
                    c.supressConnection = !c.supressConnection;
                c.forceConnection = true;
                isDirty = true;
                return c;
            }
            else
            {
                EditorConnection c = new EditorConnection(a, b, dir, forced);
                c.supressConnection = false;
                edges.Add(c);
                isDirty = true;
                return c;
            }
        }
        return null;
    }