public override void SetData(NodeData data)
    {
        base.SetData(data);
        var info      = data.data;
        int lastIndex = NodeData.lastIndex;

        currentType    = (ReturnType)info[lastIndex + 0];
        firstStatement = GetNodeByID((int)info[lastIndex + 1]);
    }
Пример #2
0
    public override void SetData(NodeData data)
    {
        base.SetData(data);
        var info      = data.data;
        int lastIndex = NodeData.lastIndex;

        fixedCycles      = (bool)info[lastIndex + 0];
        iterations       = (string)info[lastIndex + 1];
        counterVariable  = (string)info[lastIndex + 2];
        firstWithinCycle = GetNodeByID((int)info[lastIndex + 3]);
    }
    private void CheckMouseInput(Event currentE)
    {
        if (currentE.button == 1 && currentE.type == EventType.MouseDown)
        {
            GenericMenu genericMenu = new GenericMenu();

            foreach (var item in allNodes)
            {
                if (item.MyRect.Contains(currentE.mousePosition - graphPan))
                {
                    nxNode = item;
                    genericMenu.AddItem(new GUIContent("Unir Nodos"), false, JoinNodes);
                    break;
                }
            }
            genericMenu.ShowAsContext();
        }

        if (!graphRect.Contains(currentE.mousePosition) || !(focusedWindow == this || mouseOverWindow == this))
        {
            return;
        }

        if (currentE.button == 2 && currentE.type == EventType.MouseDown)
        {
            _panningScreen         = true;
            prevPan                = new Vector2(graphPan.x, graphPan.y);
            _originalMousePosition = currentE.mousePosition;
        }
        else if (currentE.button == 2 && currentE.type == EventType.MouseUp)
        {
            _panningScreen = false;
        }

        if (_panningScreen)
        {
            var newX = prevPan.x + currentE.mousePosition.x - _originalMousePosition.x;
            graphPan.x = newX > 0 ? 0 : newX;

            var newY = prevPan.y + currentE.mousePosition.y - _originalMousePosition.y;
            graphPan.y = newY > toolbarHeight ? toolbarHeight : newY;

            Repaint();
        }

        DrawnNode overNode = null;

        for (int i = 0; i < allNodes.Count; i++)
        {
            if (allNodes[i].CheckMouse(Event.current, graphPan))
            {
                overNode = allNodes[i];
                break;
            }
        }

        var prevSel = _selectedNode;

        if (currentE.button == 0 && currentE.type == EventType.MouseDown)
        {
            if (overNode != null)
            {
                _selectedNode = overNode;
            }
            else
            {
                _selectedNode = null;
            }

            if (prevSel != _selectedNode)
            {
                Repaint();
            }
        }
    }