예제 #1
0
        public void DeleteNode(NodeEditorBase node)
        {
            Undo.SetCurrentGroupName("Delete node");
            Undo.RecordObject(_graph, "Delete node");

            CleanupNode(node);

            Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
        }
        public void Update(Event e)
        {
            if (e.button != 1)
            {
                return;
            }

            if (e.type == EventType.MouseDown)
            {
                _connection  = null;
                _clickedNode = null;
                _bodyClick   = false;

                foreach (var node in _window.Nodes)
                {
                    var connection = node.GetConnection(e.mousePosition);
                    if (connection != null)
                    {
                        _connection  = node.GetConnection(e.mousePosition);
                        _clickedNode = node;
                        continue;
                    }

                    if (node.IsHeaderPosition(e.mousePosition))
                    {
                        _connection  = null;
                        _clickedNode = node;
                    }
                    else if (node.Data.rect.Contains(e.mousePosition))
                    {
                        _bodyClick = true;
                    }
                }
            }

            if (_connection != null)
            {
                GUI.FocusControl(null);
                ConnectionContextClick(e);
            }
            else if (_clickedNode == null && !_bodyClick)
            {
                GUI.FocusControl(null);
                EmptyContextClick(e);
            }
            else if (_clickedNode != null)
            {
                GUI.FocusControl(null);
                NodeContextClick(e);
            }

            if (e.type == EventType.MouseUp)
            {
                _clickedNode = null;
            }
        }
예제 #3
0
        public override void OpenGraph()
        {
            NodeEditorBase.SubmitGraph(this);

            if (m_NodePositions != null)
            {
                m_NodeManager.NodeEditorPostions = m_NodePositions;
            }
            IsOpen = true;
        }
예제 #4
0
        public void Update(Event e)
        {
            if (e.button != 0)
            {
                return;
            }

            if (e.type == EventType.MouseDown)
            {
                _connection  = null;
                _clickedNode = null;

                foreach (var node in _window.Nodes)
                {
                    var connection = node.GetConnection(e.mousePosition);
                    if (connection != null)
                    {
                        _connection  = connection;
                        _clickedNode = node;
                        continue;
                    }

                    if (node.IsHeaderPosition(e.mousePosition))
                    {
                        _connection  = null;
                        _clickedNode = node;
                    }
                }
            }

            HandleCtrlClick(e);
            if (_toggleSelectionMode)
            {
                _clickedNode = null;
                return;
            }

            if (_connection != null)
            {
                UpdateClickedConnection(e);
            }
            else if (_clickedNode == null)
            {
                DrawSelectionArea(e);
            }
            else if (_clickedNode != null)
            {
                UpdateClickedNode(e);
            }

            if (e.type == EventType.MouseUp)
            {
                _clickedNode = null;
            }
        }
예제 #5
0
        public void DuplicateNode(NodeEditorBase node)
        {
            Undo.SetCurrentGroupName("Duplicate node");
            Undo.RecordObject(_graph, "New node");

            var copy = node.CreateDataCopy();

            NewNode(copy, new Vector2(copy.rect.position.x + 50, copy.rect.position.y + 50));

            Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
        }
예제 #6
0
        private void CleanupNode(NodeEditorBase node)
        {
            Undo.RecordObject(node.Data, "Delete node");

            node.CleanConnections();
            _graph.DeleteNode(node.Data);
            _window.GraveyardAdd(node);
            Undo.DestroyObjectImmediate(node.Data);

            var childObjects = node.Data.enterActions
                               .Concat <ScriptableObject>(node.Data.exitActions)
                               .Concat(node.Data.conditions);

            foreach (var scriptableObject in childObjects)
            {
                Undo.DestroyObjectImmediate(scriptableObject);
            }

            node.DeleteCleanup();
        }
예제 #7
0
 public bool Contains(NodeEditorBase node)
 {
     return(Selected.Contains(node));
 }
예제 #8
0
 public void Remove(NodeEditorBase node)
 {
     Selected.Remove(node);
     node.Deselect();
 }
예제 #9
0
 public void Add(NodeEditorBase node)
 {
     Selected.Add(node);
     node.Select();
     Selection.activeObject = node.Data;
 }
예제 #10
0
 public void GraveyardAdd(NodeEditorBase node)
 {
     _graveyard.Add(node);
 }