public static BTNodeDesigner CreateBTreeNodeDesigner(BTEditorNodeConfig[] _configNodes, BTEditorNode[] _editorNodes, ref BTNodeDesigner[] _nodeDesigners, int _index)
        {
            BTEditorNode _editorNode = _editorNodes[_index];

            for (int i = 0; i < _editorNode.mNode.childCount; i++)
            {
                int _childIndex = _editorNode.mNode.children[i].index;
                if (_nodeDesigners[_childIndex] == null)
                {
                    _nodeDesigners[_childIndex] = CreateBTreeNodeDesigner(_configNodes, _editorNodes, ref _nodeDesigners, _childIndex);
                }
            }
            BTNodeDesigner _node = new BTNodeDesigner(_editorNode);

            //_node.m_EditorNode = _editorNode;
            //_node.m_NodeName = _editorNode.m_Node.m_Name;
            //_node.m_ChildNodeList = new List<BTreeNodeDesigner>();
            //_node.m_ChildNodeConnectionList = new List<BTreeNodeConnection>();

            for (int i = 0; i < _editorNode.mNode.childCount; i++)
            {
                int _childIndex = _editorNode.mNode.children[i].index;
                _node.mChildNodeList.Add(_nodeDesigners[_childIndex]);
                BTNodeConnection _connection = new BTNodeConnection(_nodeDesigners[_childIndex], _node, NodeConnectionType.Outgoing);
                _node.mChildNodeConnectionList.Add(_connection);
            }
            return(_node);
        }
 public static BTNodeDesigner[] CreateBTreeNodeDesignerFromConfig(BTEditorTreeConfig _config)
 {
     BTNodeDesigner[] _nodeDesigners = new BTNodeDesigner[_config.mEditorNodes.Length];
     BTEditorNode[]   _editorNodes   = CreateBTreeEditorNode(_config);
     //递归创建节点
     for (int i = 0; i < _nodeDesigners.Length; i++)
     {
         if (_nodeDesigners[i] == null)
         {
             _nodeDesigners[i] = CreateBTreeNodeDesigner(_config.mEditorNodes, _editorNodes, ref _nodeDesigners, i);
         }
     }
     //初始化父节点与连线
     for (int i = 0; i < _nodeDesigners.Length; i++)
     {
         var _editorNode = _editorNodes[i];
         if (_editorNode.mNode.parent != null)
         {
             int _parentIndex = _editorNode.mNode.parent.index;
             _nodeDesigners[i].mParentNode = _nodeDesigners[_parentIndex];
             BTNodeConnection _connection = new BTNodeConnection(_nodeDesigners[i], _nodeDesigners[_parentIndex], NodeConnectionType.Incoming);
             _nodeDesigners[i].mParentNodeConnection = _connection;
         }
     }
     return(_nodeDesigners);
 }
        public void AddParentConnectionLine(BTNodeDesigner orgNode)
        {
            BTNodeConnection line = new BTNodeConnection(this, orgNode, NodeConnectionType.Incoming);

            if (mParentNodeConnection != null)
            {
                mParentNodeConnection.mOriginatingNodeDesigner.DeleteChildNode(this);
            }
            mParentNodeConnection = line;
            mParentNode           = orgNode;
            MarkDirty();
        }
        public void AddChildNode(BTNodeDesigner destNode)
        {
            BTNodeConnection line = new BTNodeConnection(destNode, this, NodeConnectionType.Outgoing);

            if (mChildNodeConnectionList == null)
            {
                mChildNodeConnectionList = new List <BTNodeConnection>();
            }
            for (int i = 0; i < mChildNodeConnectionList.Count; i++)
            {
                if (mChildNodeConnectionList[i].mDestinationNodeDesigner.Equals(destNode))
                {
                    return;
                }
            }
            mChildNodeConnectionList.Add(line);
            mChildNodeList.Add(destNode);
            mEditorNode.AddChildNode(destNode.mEditorNode);
            destNode.AddParentConnectionLine(this);
            MarkDirty();
        }