private void CopyNode(NodeEditor editor)
        {
            Node node = editor.node.Copy();

            if (isLocal)
            {
                Undo.RegisterCompleteObjectUndo(tree, "复制结点");
            }
            else
            {
                runtimeUndo.RecordTreeChange(tree, "复制结点");
            }
            BehaviourTree.Traverse(node, n =>
            {
                CreateNewNode(n, $"({tree.Nodes.Count}) {n.GetType().Name}{(tree.IsRuntime ? "(R)" : string.Empty)}", n._position + new Vector2(30, 30));
            });
            DrawTreeView(tree);
        }
Example #2
0
        /// <summary>
        /// 找包含某节点的分支下标
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private int FindBranchIndex(Node node)
        {
            for (int i = 0; i < children.Count; i++)
            {
                bool find = false;
                BehaviourTree.Traverse(children[i], accesser);
                if (find)
                {
                    return(i);
                }

                bool accesser(Node child)
                {
                    if (child == node)
                    {
                        find = true;
                        return(true);
                    }
                    return(false);
                }
            }
            return(-1);
        }