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); }
public UINode DrawLayer(LayerInfo layer) { UINode node = mechine.CreateRootNode(layer); return(node); }
public static void LoadCommonResources(AssemblerStateMechine mechine, UINode node) { LoadCommonResources(mechine, node, node.layerInfo.rect); }