private void MakeRelation(UINode rootNode, UINode[] uiNodes)
        {
            if (rootNode == null || uiNodes == null)
            {
                return;
            }
            var pathCatchDic    = new Dictionary <string, string[]>();
            var nodeTemplateDic = new Dictionary <string, UINode>();
            var deepthDic       = new Dictionary <int, List <UINode> >();
            var maxdeepth       = 0;

            ///建立索引
            for (int i = 0; i < uiNodes.Length; i++)
            {
                var node = uiNodes[i];
                nodeTemplateDic.Add(node.path, node);
                var pathArray = LayerImportUtil.PathToArray(node.path);
                pathCatchDic.Add(node.path, pathArray);

                var deepth = pathArray.Length;

                if (deepthDic.ContainsKey(deepth))
                {
                    deepthDic[deepth].Add(node);
                }
                else
                {
                    deepthDic[deepth] = new List <UINode>()
                    {
                        node
                    };
                }

                maxdeepth = maxdeepth > deepth ? maxdeepth : deepth;
            }

            ///关系对应
            for (int deepth = 1; deepth <= maxdeepth; deepth++)
            {
                var nodes = deepthDic[deepth];
                for (int k = 0; k < nodes.Count; k++)
                {
                    var node = nodes[k];
                    var path = pathCatchDic[node.path];

                    var parentPath = LayerImportUtil.ArrayToPath(path, deepth - 1);

                    if (string.IsNullOrEmpty(parentPath))
                    {
                        rootNode.AddChildNode(node);
                    }
                    else if (nodeTemplateDic.ContainsKey(parentPath))
                    {
                        var nodeTemp = nodeTemplateDic[parentPath];
                        nodeTemp.AddChildNode(node);
                    }
                    else
                    {
                        Debug.LogWarning("未找到层级:" + parentPath);
                    }
                }
            }
            //设置父级
            SetUIParentsDeepth(rootNode);
        }
        private UINode[] CompleteEmptyNodes(UINode[] uiNodes)
        {
            var pathCatchDic    = new Dictionary <string, string[]>();
            var nodeTemplateDic = new Dictionary <string, UINode>();
            var neededNodes     = new Dictionary <string, List <UINode> >();
            var emptyNodes      = new List <UINode>();
            var maxdeepth       = 0;

            ///确定深度,记录索引
            for (int i = 0; i < uiNodes.Length; i++)
            {
                var node = uiNodes[i];

                if (string.IsNullOrEmpty(node.path))
                {
                    continue;
                }

                nodeTemplateDic.Add(node.path, node);
                var pathArray = LayerImportUtil.PathToArray(node.path);
                pathCatchDic.Add(node.path, pathArray);

                var deepth = pathArray.Length;
                maxdeepth = maxdeepth > deepth ? maxdeepth : deepth;
            }

            ///查找所有空节点的实体子节点
            for (int i = 0; i < uiNodes.Length; i++)
            {
                var node = uiNodes[i];

                if (string.IsNullOrEmpty(node.path))
                {
                    continue;
                }

                var path = pathCatchDic[node.path];

                for (int j = path.Length; j > 0; j--)
                {
                    var parentPath = LayerImportUtil.ArrayToPath(path, j - 1);
                    if (!string.IsNullOrEmpty(parentPath))
                    {
                        if (!nodeTemplateDic.ContainsKey(parentPath))
                        {
                            if (neededNodes.ContainsKey(parentPath))
                            {
                                if (!neededNodes[parentPath].Contains(node))
                                {
                                    neededNodes[parentPath].Add(node);
                                }
                            }
                            else
                            {
                                neededNodes.Add(parentPath, new List <UINode>()
                                {
                                    node
                                });
                            }
                        }
                    }
                }
            }

            ///创建节点
            using (var enumerator = neededNodes.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    var current = enumerator.Current;
                    var rects   = new Rect[current.Value.Count];
                    for (int i = 0; i < rects.Length; i++)
                    {
                        rects[i] = current.Value[i].layerInfo.rect;
                    }
                    var info = new LayerInfo();
                    info.path = current.Key;
                    info.rect = LayerImportUtil.GetRectContent(rects);
                    var emptyNode = DrawLayer(info);
                    emptyNodes.Add(emptyNode);
                }
            }

            return(emptyNodes.ToArray());
        }