/// <summary> /// Paste the supplied nodes in the supplied ActionState. /// <param name="actionState">The ActionState to paste the node.</param> /// <param name="nodes">The nodes to be pasted.</param> /// <returns>The pasted nodes.</returns> /// </summary> public static ActionNode[] PasteNodes (InternalActionState actionState, ActionNode[] nodes) { var newNodes = new List<ActionNode>(); // Validate parameters if (nodes != null && actionState != null) { // Register Undo #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2 Undo.RegisterUndo(actionState,"Paste Node"); #else Undo.RecordObject(actionState,"Paste Node"); #endif // Copy nodes for (int i = 0; i < nodes.Length; i++) { if (nodes[i] != null && !(nodes[i] is BranchNode)) { ActionNode newNode = nodes[i].Copy(actionState); if (newNode != null) newNodes.Add(newNode); } } if (newNodes.Count > 0) { // Saves node and sets dirty flag StateUtility.SetDirty(actionState); // Reload actionState to update variables actionState.LoadNodes(); } } return newNodes.ToArray(); }
/// <summary> /// A Unity callback called when the object is loaded. /// </summary> private void OnEnable () { m_ActionState = target as InternalActionState; BehaviourWindow.activeNodeChanged += this.ActiveNodeChanged; // Try to create an editor for the current active node this.ActiveNodeChanged(); // Register the visual debugging callback ActionNode.onNodeTick += OnNodeTick; // Register Update if (Application.isPlaying) { EditorApplication.update += this.Update; } else { m_ActionState.LoadNodes(); RegisterEditorOnGUI(); } }