public override void Redo() { if (CanRedo) { BTEditorGraphNode parentNode = m_graph.GetNodeByHash(m_parentNodeHash); BehaviourNode node = BTUtils.DeserializeNode(m_serializedNode); BTEditorGraphNode createdNode = parentNode.OnCreateChild(node); m_createdNodeHash = m_graph.GetNodeHash(createdNode); m_parentNodeHash = null; m_serializedNode = null; } }
public void OnPasteNode(BTEditorGraphNode destination) { if (CanPaste(destination)) { BehaviourNode node = BTUtils.DeserializeNode(BTEditorCanvas.Current.Clipboard); BTEditorGraphNode child = destination.OnCreateChild(node); if (child != null) { SelectBranch(child); var undoState = new UndoNodeCreated(child); undoState.Title = "Pasted " + child.Node.Title; BTUndoSystem.RegisterUndo(undoState); } } }
public override void Undo() { if (CanUndo) { BehaviourNode node = BTUtils.DeserializeNode(m_serializedNode); if (m_childIndex >= 0) { var parentNode = m_graph.GetNodeByHash(m_parentNodeHash); var createdNode = parentNode.OnInsertChild(m_childIndex, node); m_createdNodeHash = m_graph.GetNodeHash(createdNode); } else { var parentNode = m_graph.GetNodeByHash(m_parentNodeHash); var createdNode = parentNode.OnCreateChild(node); m_createdNodeHash = m_graph.GetNodeHash(createdNode); } m_parentNodeHash = null; m_serializedNode = null; } }