コード例 #1
0
        private void UpdateClickedConnection(Event e)
        {
            switch (e.type)
            {
            case EventType.MouseDrag:
                _connection.SetExampleCurve(e.mousePosition);
                break;

            case EventType.MouseUp:
                Connection linkTarget = null;
                foreach (var node in _window.Nodes)
                {
                    linkTarget = node.GetConnection(e.mousePosition);
                    if (linkTarget != null)
                    {
                        break;
                    }
                }

                _connection.Links.AddLink(linkTarget);
                _connection.ClearCurveExample();
                DialogueWindow.SaveGraph();

                break;
            }
        }
コード例 #2
0
        private void UpdateClickedNode(Event e)
        {
            switch (e.type)
            {
            case EventType.MouseDown when !_selection.Contains(_clickedNode):
                _selection.RemoveAll();
                _selection.Add(_clickedNode);
                GUI.changed = true;
                break;

            case EventType.MouseDrag:
                _isDraggingNode = true;
                Undo.SetCurrentGroupName("Drag nodes");
                _selection.Selected.ForEach(n => {
                    Undo.RegisterCompleteObjectUndo(n.Data, "Move node");
                    n.Data.rect.position += e.delta;
                });
                Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                e.Use();
                break;

            case EventType.MouseUp:
                if (!_isDraggingNode)
                {
                    _selection.RemoveAll();
                    _selection.Add(_clickedNode);
                    GUI.changed = true;
                }

                ClearDragging();
                DialogueWindow.SaveGraph();
                break;

            case EventType.Ignore:
                ClearDragging();
                DialogueWindow.SaveGraph();
                break;
            }
        }