Beispiel #1
0
        /// <summary>
        /// 转换为组
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="group"></param>
        /// <param name="OnRetrive"></param>
        public static void RetriveLayerToSwitchModle(Vector2 rootSize, PsdLayer layer, GroupNodeItem 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)
                    {
                        GroupNodeItem childNode = new GroupNodeItem(GetRectFromLayer(child), idSpan++, group.depth + 1);
                        childNode.Analyzing(RuleObj, child.Name);
                        group.AddChild(childNode);

                        if (childNode != null)
                        {
                            RetriveLayerToSwitchModle(rootSize, child, childNode, forceSprite);
                        }
                    }

                    else
                    {
                        Data.ImgNode imgnode = AnalysisLayer(group.displayName, rootSize, child, forceSprite);
                        if (imgnode != null)
                        {
                            group.images.Add(imgnode);
                        }
                    }
                }
                EditorUtility.ClearProgressBar();
            }
        }
Beispiel #2
0
        public static GroupNodeItem[] CreatePictures(IPsdLayer[] rootLayers, Vector2 rootSize, Vector2 uiSize, bool forceSprite = false)
        {
            maxSize = uiSize;
            List <GroupNodeItem> nodes = new List <GroupNodeItem>();

            foreach (PsdLayer rootLayer in rootLayers)
            {
                if (rootLayer.IsGroup)
                {
                    var groupnode = new GroupNodeItem(GetRectFromLayer(rootLayer), idSpan++, 0);
                    groupnode.Analyzing(ExportUtility.RuleObj, rootLayer.Name);// (rootLayer,rootLayer));
                    RetriveLayerToSwitchModle(rootSize, rootLayer, groupnode, forceSprite);
                    nodes.Add(groupnode);
                }
            }

            var pictureData = new List <Data.ImgNode>();

            foreach (var groupnode in nodes)
            {
                groupnode.GetImgNodes(pictureData);
            }

            #region 去除名称重复
            var simplyed = new List <Data.ImgNode>();
            foreach (var item in pictureData)
            {
                if (simplyed.Find(x => x.TextureName == item.TextureName) == null)
                {
                    simplyed.Add(item);
                }
            }
            #endregion

            SwitchCreateTexture(simplyed);
            return(nodes.ToArray());
        }