public GameObject GenerateUI(UIInfo uiInfo)
        {
            if (layerImportDic == null)
            {
                Debug.Log("LayerImportDic 未初始化");
                return(null);
            }

            if (uiInfo == null || uiInfo.layers == null)
            {
                return(null);
            }

            var canvasNode = new UINode(canvas.transform);

            var rootTransform = new GameObject(uiInfo.name, typeof(RectTransform)).GetComponent <RectTransform>();

            rootTransform.SetParent(canvas.transform, false);
            rootTransform.sizeDelta = uiSize;
            var rootNode = new UINode(rootTransform);

            canvasNode.AddChildNode(rootNode);

            ClearEmptMakeEffectiveyLayers(uiInfo.layers);
            var uiNodes = DrawLayers(uiInfo.layers); //绘制所有层级

            MakeRelation(rootNode, uiNodes);         //设置父子关系
            SetCustomResource(rootNode);             //设置配制的资源参数
            SetAnchorDeepth(rootNode);               //设置默认锚点
            DoAnchorCompleteAction(rootNode);        //只有锚点设置好了才能进行的事
            return(rootTransform.gameObject);
        }
        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);
        }