/// <summary> /// 转换为组 /// </summary> /// <param name="layer"></param> /// <param name="group"></param> /// <param name="OnRetrive"></param> public static void RetriveLayerToSwitchModle(Vector2 rootSize, PsdLayer layer, GroupNode group, bool forceSprite = false) { if (!layer.IsGroup) { return; } else { float index = 0; foreach (var child in layer.Childs) { var progress = ++index / layer.Childs.Length; EditorUtility.DisplayProgressBar(layer.Name, "转换进度:" + progress, progress); if (child.IsGroup) { GroupNode childNode = new GroupNode(GetRectFromLayer(child), idSpan++, group.depth + 1); childNode.Analyzing(RuleObj, child.Name); group.AddChild(childNode); if (childNode != null) { RetriveLayerToSwitchModle(rootSize, child, childNode, forceSprite); } } else { ImgNode imgnode = AnalysisLayer(group.displayName, rootSize, child, forceSprite); if (imgnode != null) { group.images.Add(imgnode); } } } EditorUtility.ClearProgressBar(); } }
public static GroupNode[] CreatePictures(IPsdLayer[] rootLayers, Vector2 rootSize, Vector2 uiSize, bool forceSprite = false) { maxSize = uiSize; List <GroupNode> nodes = new List <GroupNode>(); foreach (PsdLayer rootLayer in rootLayers) { if (rootLayer.IsGroup) { var groupnode = new GroupNode(GetRectFromLayer(rootLayer), idSpan++, 0); groupnode.Analyzing(ExportUtility.RuleObj, rootLayer.Name);// (rootLayer,rootLayer)); RetriveLayerToSwitchModle(rootSize, rootLayer, groupnode, forceSprite); nodes.Add(groupnode); } } var pictureData = new List <ImgNode>(); foreach (var groupnode in nodes) { groupnode.GetImgNodes(pictureData); } #region 去除名称重复 var simplyed = new List <ImgNode>(); foreach (var item in pictureData) { if (simplyed.Find(x => x.TextureName == item.TextureName) == null) { simplyed.Add(item); } } #endregion SwitchCreateTexture(simplyed); return(nodes.ToArray()); }