Ejemplo n.º 1
0
        internal SelectBoxElement(string name, IPsdLayer layer, ElementType type, IPsdLayer[] childs) : base(name,
                                                                                                             layer, type, childs)
        {
            normal = FindChildElement(normalSuffix);
            if (normal != null)
            {
                normalPiece = new TexturePiece(name + normalSuffix, GetTexture2D(normal));
            }
            else
            {
                canShow = false;
                P2UUtil.AddError("勾选框:" + name + "需要有一张未选择态的图");
            }

            select = FindChildElement(selectSuffix);
            if (select != null)
            {
                selectPiece = new TexturePiece(name + selectSuffix, GetTexture2D(select));
            }
            else
            {
                canShow = false;
                P2UUtil.AddError("勾选框:" + name + "需要有一张选择态的图");
            }
        }
Ejemplo n.º 2
0
        public void GetAppFontInfo(IPsdLayer psdLayer)
        {
            fontIds.Clear();

            if (psdLayer.Name == "Text_Set")
            {
            }

            var resourceDict = engineData["ResourceDict"] as Properties;
            var fontSetArray = resourceDict["FontSet"] as ArrayList;

            foreach (var v in fontSetArray)
            {
                var properties = v as Properties;
                var id         = properties["Name"] as string;
                fontIds.Add(id);
            }

            foreach (var fontId in fontIds)
            {
                if (AppFontIds.Contains(fontId))
                {
                    FontName = fontId;
                    Debug.Log($"图层{psdLayer.Name}的字体Id为{FontName}!");
                    return;
                }
            }
            FontName = XTwoDefaultFontName;
            Debug.LogError($"图层{psdLayer.Name}的字体无法识别!,自动替换为 ContentFont 字体");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 根据其类型生成相应的Element
 /// </summary>
 /// <param name="name">element的名字</param>
 /// <param name="layer">对应的PsdLayer</param>
 /// <param name="type">Element的类型</param>
 /// <param name="childs">当类型为组时,所带的子PsdLayer</param>
 /// <returns>生成的对应类型的PsdElement</returns>
 public static PsdElement GetPsdElement(string name, IPsdLayer layer, PsdElement.ElementType type,
                                        IPsdLayer[] childs)
 {
     if (type == PsdElement.ElementType.Image)
     {
         return(new ImageElement(name, layer, type, childs));
     }
     if (type == PsdElement.ElementType.Image9)
     {
         return(new Image9Element(name, layer, type, childs));
     }
     if (type == PsdElement.ElementType.Button)
     {
         return(new ButtonElement(name, layer, type, childs));
     }
     if (type == PsdElement.ElementType.Text)
     {
         return(new TextElement(name, layer, type, childs));
     }
     if (type == PsdElement.ElementType.List)
     {
         return(new ListElement(name, layer, type, childs));
     }
     if (type == PsdElement.ElementType.SelectBox)
     {
         return(new SelectBoxElement(name, layer, type, childs));
     }
     return(new PsdElement(name, layer, type, childs));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Get the path
        /// </summary>
        private GraphicPath ParsePath(IPsdLayer layer, Size size)
        {
            var graphicPath = new GraphicPath();

            foreach (var resource in layer.Resources)
            {
                switch (resource)
                {
                // vector mask equals paths
                // vsmsResource inherits from smsk: we don't need to add the extra 'case'
                case vmskResource vmsk:
                {
                    ReadBezier(vmsk.Beziers, graphicPath, size);
                    break;
                }
                }
            }

            if (graphicPath.Geometry.Segments.Count == 0)
            {
                graphicPath = null;
            }

            return(graphicPath);
        }
Ejemplo n.º 5
0
        public Image9Element(string name, IPsdLayer layer, ElementType type, IPsdLayer[] childs) : base(name, layer,
                                                                                                        type, childs)
        {
            Png9 = FindChildElement(png9Suffix);
            if (Png9 != null)
            {
                Png9Piece = new TexturePiece(name, GetTexture2D(Png9), true);
            }
            else
            {
                canShow = false;
                P2UUtil.AddError("九宫格图:" + name + "需要有一张九宫格大小的图");
            }

            Preview = FindChildElement(previewSuffix);
            if (Preview != null)
            {
                PreviewPiece = new TexturePiece(name + previewSuffix, GetTexture2D(Preview), false);
            }
            else
            {
                canShow = false;
                P2UUtil.AddError("九宫格图:" + name + "需要有一张预览图来决定其大小");
            }
        }
Ejemplo n.º 6
0
        //生成Preview
        public override void ModifyToPreview(RectTransform root, RectTransform t)
        {
            ModifySize(root, t, this.normal);
            Rect btnRect = new Rect(0, 0, this.normal.Width, this.normal.Height);

            Image  image  = t.gameObject.AddComponent <Image>();
            Button button = t.gameObject.AddComponent <Button>();

            button.targetGraphic = image;
            Sprite normal = Sprite.Create(normalPiece.tex, btnRect, Vector2.zero);

            image.sprite = normal;

            if (pressed != null || disabled != null)
            {
                button.transition = Selectable.Transition.SpriteSwap;
                Sprite pressed  = null;
                Sprite disabled = null;
                if (this.pressed != null)
                {
                    pressed = Sprite.Create(pressedPiece.tex, btnRect, Vector2.zero);
                }
                if (this.disabled != null)
                {
                    disabled = Sprite.Create(disabledPiece.tex, btnRect, Vector2.zero);
                }
                SpriteState state = new SpriteState();
                state.pressedSprite  = pressed;
                state.disabledSprite = disabled;
                button.spriteState   = state;
            }
        }
Ejemplo n.º 7
0
        //初始化
        internal ButtonElement(string name, IPsdLayer layer, ElementType type, IPsdLayer[] childs) : base(name, layer,
                                                                                                          type, childs)
        {
            var normalSuffix   = "@normal";
            var pressedSuffix  = "@pressed";
            var disabledSuffix = "@disabled";

            normal = FindChildElement(normalSuffix);
            if (normal != null && normal.HasImage)
            {
                normalPiece = new TexturePiece(name + normalSuffix, GetTexture2D(normal));
            }
            else
            {
                canShow = false;
                P2UUtil.AddError("按钮:" + name + "至少要有一张正常态的图片");
            }

            pressed = FindChildElement(pressedSuffix);
            if (pressed != null && pressed.HasImage)
            {
                pressedPiece = new TexturePiece(name + pressedSuffix, GetTexture2D(pressed));
            }

            disabled = FindChildElement(disabledSuffix);
            if (disabled != null && disabled.HasImage)
            {
                disabledPiece = new TexturePiece(name + disabledSuffix, GetTexture2D(disabled));
            }
        }
Ejemplo n.º 8
0
    public Texture2D GetTexture2D(IPsdLayer layer)
    {
        byte[] data = null;
        try {
            data = layer.MergeChannels();
        } catch (System.Exception e) {
            UnityEngine.Debug.Log(e);
        }
        if (data == null)
        {
            return(null);
        }

        var channelCount = layer.Channels.Length;
        var pitch        = layer.Width * layer.Channels.Length;
        var w            = layer.Width;
        var h            = layer.Height;

        var format = channelCount == 3 ? TextureFormat.RGB24 : TextureFormat.ARGB32;
        var tex    = new Texture2D(w, h, format, false);
        var colors = new Color32[data.Length / channelCount];

        var k = 0;

        for (var y = h - 1; y >= 0; --y)
        {
            for (var x = 0; x < pitch; x += channelCount)
            {
                var n = x + y * pitch;
                var c = new Color32();
                if (channelCount == 5)
                {
                    c.b = data[n++];
                    c.g = data[n++];
                    c.r = data[n++];
                    n++;
                    c.a = (byte)Mathf.RoundToInt((float)(data[n++]) * layer.Opacity);
                }
                else if (channelCount == 4)
                {
                    c.b = data[n++];
                    c.g = data[n++];
                    c.r = data[n++];
                    c.a = (byte)Mathf.RoundToInt((float)data[n++] * layer.Opacity);
                }
                else
                {
                    c.b = data[n++];
                    c.g = data[n++];
                    c.r = data[n++];
                    c.a = (byte)Mathf.RoundToInt(layer.Opacity * 255f);
                }
                colors[k++] = c;
            }
        }
        tex.SetPixels32(colors);
        tex.Apply(false, true);
        return(tex);
    }
Ejemplo n.º 9
0
 public PsdElement(string name, IPsdLayer layer, ElementType type, IPsdLayer[] childs)
 {
     this.name   = name;
     this.layer  = layer;
     this.type   = type;
     this.childs = childs;
     canShow     = true;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 获取相对坐标
        /// </summary>
        /// <param name="psdLayer"></param>
        /// <param name="rootRect"></param>
        /// <returns></returns>
        private static Rect GetSubRectFromLayer(IPsdLayer psdLayer, Rect rootRect)
        {
            var rect = GetRectFromLayer(psdLayer);

            rect.x = rect.x - rootRect.x;
            rect.y = rect.y - rootRect.y;
            return(rect);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 解析Layer中的尺寸信息
        /// </summary>
        /// <param name="psdLayer"></param>
        /// <returns></returns>
        private static Rect GetRectFromLayer(IPsdLayer psdLayer)
        {
            var left   = psdLayer.Left;
            var top    = psdLayer.Top;
            var width  = psdLayer.Width;
            var height = psdLayer.Height;

            return(new Rect(left, top, width, height));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Get the colors
        /// </summary>
        private void ParseColors(IPsdLayer layer, GraphicPath graphicPath)
        {
            var bounds      = graphicPath.Geometry.Bounds;
            var aspectRatio = bounds.Height / bounds.Width;

            foreach (var resource in layer.Resources)
            {
                switch (resource)
                {
                // backwards compatibility solid color
                case vscgResource vscg:
                {
                    var(color, colorPrecision) = colorManager.GetBrush(vscg.Color, aspectRatio, false);
                    graphicPath.FillBrush      = color;
                    graphicPath.ColorPrecision = colorPrecision;
                    break;
                }

                // solid color
                case SoCoResource soCo:
                {
                    var(color, colorPrecision) = colorManager.GetBrush(soCo.Color, aspectRatio, false);
                    graphicPath.FillBrush      = color;
                    graphicPath.ColorPrecision = colorPrecision;
                    break;
                }

                // pattern fill
                case PtFlResource ptFl:
                {
                    var(color, colorPrecision) = colorManager.GetBrush(ptFl.Color, aspectRatio, false);
                    graphicPath.FillBrush      = color;
                    graphicPath.ColorPrecision = colorPrecision;
                    break;
                }

                // gradient fill
                case GdFlResource gdFl:
                {
                    var(color, colorPrecision) = colorManager.GetBrush(gdFl.Color, aspectRatio, false);
                    graphicPath.FillBrush      = color;
                    graphicPath.ColorPrecision = colorPrecision;
                    break;
                }

                // stroke infos
                case vstkResource vstk:
                {
                    var(color, colorPrecision)  = colorManager.GetBrush(vstk.Color, aspectRatio, true);
                    graphicPath.StrokeBrush     = color;
                    graphicPath.StrokeThickness = vstk.Width;
                    graphicPath.ColorPrecision  = colorPrecision;
                    break;
                }
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 偏移
        /// </summary>
        /// <param name="psdLayer"></param>
        /// <param name="rootRect"></param>
        /// <returns></returns>
        private static Rect GetPaddingFromLayer(IPsdLayer psdLayer, Rect rootRect)
        {
            var rect = GetRectFromLayer(psdLayer);

            var left    = rootRect.x - rect.x;
            var top     = rootRect.y - rect.y;
            var right   = rootRect.width - rect.width - left;
            var bottom  = rootRect.height - rect.height - top;
            var padding = new Rect(left, top, right, bottom);

            return(padding);
        }
Ejemplo n.º 14
0
        private static string GetFullPath(IPsdLayer layer)
        {
            var path    = new List <string>();
            var current = layer;

            while (!(current is PsdDocument))
            {
                path.Insert(0, current.Name);
                current = current.Parent;
            }
            return(string.Join("/", path.ToArray()));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Parse one layer
        /// </summary>
        private GraphicPath ParseLayer(IPsdLayer layer, Size size)
        {
            GraphicPath graphicPath = ParsePath(layer, size);

            if (graphicPath == null || graphicPath.Geometry.Segments.Count == 0)
            {
                return(null);
            }

            ParseColors(layer, graphicPath);

            return(graphicPath);
        }
Ejemplo n.º 16
0
    //生成PS图层的贴图
    Texture2D GetTexture2D(IPsdLayer layer)
    {
        byte[] data = layer.MergeChannels();
        var channelCount = layer.Channels.Length;
        var pitch = layer.Width * layer.Channels.Length;
        var w = layer.Width;
        var h = layer.Height;

        var format = channelCount == 3 ? TextureFormat.RGB24 : TextureFormat.ARGB32;
        var tex = new Texture2D(w, h, format, false);
        var colors = new Color32[data.Length / channelCount];

        var k = 0;
        for (var y = h - 1; y >= 0; --y)
        {
            for (var x = 0; x < pitch; x += channelCount)
            {
                var n = x + y * pitch;
                var c = new Color32();
                if (channelCount == 5)
                {
                    c.b = data[n++];
                    c.g = data[n++];
                    c.r = data[n++];
                    n++;
                    c.a = (byte)Mathf.RoundToInt((float)(data[n++]) * layer.Opacity);
                }
                else if (channelCount == 4)
                {
                    c.b = data[n++];
                    c.g = data[n++];
                    c.r = data[n++];
                    c.a = (byte)Mathf.RoundToInt((float)data[n++] * layer.Opacity);
                }
                else
                {
                    c.b = data[n++];
                    c.g = data[n++];
                    c.r = data[n++];
                    c.a = (byte)Mathf.RoundToInt(layer.Opacity * 255f);
                }
                colors[k++] = c;
            }
        }
        tex.SetPixels32(colors);
        tex.Apply(false, true);

        tex.filterMode = filterMode;

        return tex;
    }
Ejemplo n.º 17
0
        //找到子项
        protected IPsdLayer FindChildElement(string suffix)
        {
            IPsdLayer childElement = null;

            foreach (var child in childs)
            {
                if (child.Name.EndsWith(suffix))
                {
                    childElement = child;
                }
            }

            return(childElement);
        }
Ejemplo n.º 18
0
 internal ListElement(string name, IPsdLayer layer, ElementType type, IPsdLayer[] childs) : base(name, layer,
                                                                                                 type, childs)
 {
     Background = FindChildElement(backgroundSuffix);
     if (Background != null && Background.HasImage)
     {
         BackgroundPiece = new TexturePiece(name + backgroundSuffix, GetTexture2D(Background));
     }
     else
     {
         canShow = false;
         P2UUtil.AddError("列表:" + name + "需要有一张背景图来确定列表区域");
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 解析Layer中的尺寸信息
        /// </summary>
        /// <param name="psdLayer"></param>
        /// <returns></returns>
        public static Rect GetRectFromLayer(IPsdLayer psdLayer)
        {
            //rootSize = new Vector2(rootSize.x > maxSize.x ? maxSize.x : rootSize.x, rootSize.y > maxSize.y ? maxSize.y : rootSize.y);
            var left   = psdLayer.Left;   // psdLayer.Left <= 0 ? 0 : psdLayer.Left;
            var bottom = psdLayer.Bottom; // psdLayer.Bottom <= 0 ? 0 : psdLayer.Bottom;
            var top    = psdLayer.Top;    // psdLayer.Top >= rootSize.y ? rootSize.y : psdLayer.Top;
            var rigtht = psdLayer.Right;  // psdLayer.Right >= rootSize.x ? rootSize.x : psdLayer.Right;
            var width  = psdLayer.Width;  // psdLayer.Width > rootSize.x ? rootSize.x : psdLayer.Width;
            var height = psdLayer.Height; // psdLayer.Height > rootSize.y ? rootSize.y : psdLayer.Height;

            var xMin = (rigtht + left - rootSize.x) * 0.5f;
            var yMin = -(top + bottom - rootSize.y) * 0.5f;

            return(new Rect(xMin, yMin, width, height));
        }
Ejemplo n.º 20
0
        //生成UI
        public override void ModifyToUi(RectTransform root, RectTransform t, string[] sourceDirs)
        {
            TextMeshProUGUI text = t.GetComponent <TextMeshProUGUI>();

            if (text == null)
            {
                text = t.gameObject.AddComponent <TextMeshProUGUI>();
                ModifySize(root, t, this.text);
            }

            if (text.text == default)
            {
                text.text = Regex.Match(name, "(?!.*-).+").ToString();
            }
        }
Ejemplo n.º 21
0
        public LayerItemViewModel(IPsdLayer layer, PSDItemViewModel parent)
            : base(parent)
        {
            this.layer = layer;

            foreach (var item in layer.Childs)
            {
                this.Children.Add(new LayerItemViewModel(item, parent));
            }

            if(layer.LinkedLayer != null)
            {
                this.Children.Add(new LinkedLayerItemViewModel(layer.LinkedLayer, parent));
            }

            //this.Children.Add(new PropertiesItemViewModel("Resources", layer.Resources, this));
        }
Ejemplo n.º 22
0
        private static PsdLayer GetPsdLayerByIndex(PsdDocument psdDoc, int[] layerIdx)
        {
            IPsdLayer target = psdDoc;

            foreach (int idx in layerIdx)
            {
                if (idx < 0 || idx >= target.Childs.Length)
                {
                    return(null);
                }
                target = target.Childs[idx];
            }

            PsdLayer layer = target as PsdLayer;

            return(layer);
        }
Ejemplo n.º 23
0
        public LayerItemViewModel(IPsdLayer layer, PSDItemViewModel parent)
        {
            this.layer = layer;

            foreach (var item in layer.Childs)
            {
                this.Items.Add(new LayerItemViewModel(item, parent));
            }

            if (layer.LinkedLayer != null)
            {
                this.Items.Add(new LinkedLayerItemViewModel(layer.LinkedLayer, parent));
            }

            this.Items.Add(new PropertiesItemViewModel("Resources", layer.Resources, this));
            this.previewCommand = new DelegateCommand((p) => this.Preview(), (p) => this.CanPreview);
        }
Ejemplo n.º 24
0
        public static IEnumerable <IPsdLayer> Descendants(this IPsdLayer layer, Func <IPsdLayer, bool> filter)
        {
            foreach (var item in layer.Childs)
            {
                if (filter(item) == false)
                {
                    continue;
                }

                yield return(item);

                foreach (var child in item.Descendants(filter))
                {
                    yield return(child);
                }
            }
        }
Ejemplo n.º 25
0
        // Image
        public static Texture2D GetTexture2DFromPsdLayer(IPsdLayer layer)
        {
            IChannel[] channels = layer.Channels;

            IChannel rChannel = channels.FirstOrDefault(channel => channel.Type == ChannelType.Red);
            IChannel gChannel = channels.FirstOrDefault(channel => channel.Type == ChannelType.Green);
            IChannel bChannel = channels.FirstOrDefault(channel => channel.Type == ChannelType.Blue);
            IChannel aChannel = channels.FirstOrDefault(channel => channel.Type == ChannelType.Alpha);

            int width      = layer.Width;
            int height     = layer.Height;
            int pixelCount = width * height;

            if (pixelCount == 0)
            {
                Debug.LogWarningFormat("Encounter 0 pixel layer at {0}", layer.Name);
                return(null);
            }

            var pixelArray = new Color32[pixelCount];

            // Unity texture coordinates start at lower left corner.
            // Photoshop coordinates start at upper left corner.
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int photoshopIndex    = x + y * width;
                    int unityTextureIndex = x + (height - 1 - y) * width;

                    byte r = rChannel != null ? rChannel.Data[photoshopIndex] : (byte)0;
                    byte g = gChannel != null ? gChannel.Data[photoshopIndex] : (byte)0;
                    byte b = bChannel != null ? bChannel.Data[photoshopIndex] : (byte)0;
                    byte a = aChannel != null ? aChannel.Data[photoshopIndex] : (byte)255;

                    pixelArray[unityTextureIndex] = new Color32(r, g, b, a);
                }
            }

            var outputTexture2D = new Texture2D(width, height);

            outputTexture2D.SetPixels32(pixelArray);
            outputTexture2D.Apply();

            return(outputTexture2D);
        }
Ejemplo n.º 26
0
        public LayerItemViewModel(IPsdLayer layer, PSDItemViewModel parent)
            : base(parent)
        {
            this.layer = layer;

            foreach (var item in layer.Childs)
            {
                this.Children.Add(new LayerItemViewModel(item, parent));
            }

            if (layer.LinkedLayer != null)
            {
                this.Children.Add(new LinkedLayerItemViewModel(layer.LinkedLayer, parent));
            }

            //this.Children.Add(new PropertiesItemViewModel("Resources", layer.Resources, this));
        }
Ejemplo n.º 27
0
 private static void ProcessChildren(PsdDocument psd, PfiFolder folder, IPsdLayer psdLayer)
 {
     for (int i = 0; i < psdLayer.Childs.Length; i++)
     {
         var child = psdLayer.Childs[i] as PsdLayer;
         if (child.HasImage)
         {
             var layer = ProcessImageLayer(psd, child);
             layer.parent = folder;
             folder.layers.Add(layer);
         }
         else
         {
             var childFolder = new PfiFolder(child.Name);
             childFolder.parent = folder;
             ProcessChildren(psd, childFolder, child);
             folder.subFolders.Add(childFolder);
         }
     }
 }
Ejemplo n.º 28
0
        //调整大小
        protected void ModifySize(RectTransform root, RectTransform t, IPsdLayer layer)
        {
            var parent       = t.parent;
            var siblingIndex = t.GetSiblingIndex();

            t.SetParent(root);
            t.pivot = new Vector2(0.5f, 0.5f);

            Vector2 rootSize   = root.rect.size;
            Vector2 rootOffest = -rootSize / 2f;

            var texLayer = layer;

            t.anchoredPosition = new Vector2(
                texLayer.Left + texLayer.Width / 2f,
                rootSize.y - (texLayer.Top + texLayer.Height / 2f)
                ) + rootOffest;
            t.sizeDelta = new Vector2(texLayer.Width, texLayer.Height);

            t.SetParent(parent);
            t.SetSiblingIndex(siblingIndex);
        }
Ejemplo n.º 29
0
            public LayerNode(IPsdLayer layer)
            {
                this.layer = layer;
                if (layer is PsdDocument)
                {
                    layerType = LayerType.Group;
                }
                else
                {
                    layerType = (layer as PsdLayer).LayerType;
                }
                switch (layerType)
                {
                case LayerType.Normal:
                    _spritenormal = new GUIContent(layer.Name, EditorGUIUtility.IconContent("createrect").image);
                    break;

                case LayerType.SolidImage:
                    _spritenormal = new GUIContent(layer.Name, EditorGUIUtility.IconContent("iconselector back").image);
                    break;

                case LayerType.Text:
                    _spritenormal = new GUIContent(layer.Name, EditorGUIUtility.IconContent("eventpin").image);
                    break;

                case LayerType.Group:
                    _groupff = new GUIContent(layer.Name, EditorGUIUtility.IconContent("IN foldout focus").image);
                    _groupOn = new GUIContent(layer.Name, EditorGUIUtility.IconContent("IN foldout focus on").image);
                    break;

                default:
                    break;
                }

                content    = layerType == LayerType.Group ? _groupOn : _spritenormal;
                isExpanded = true;
            }
Ejemplo n.º 30
0
        /// <summary>
        /// Parse all layers recursively
        /// </summary>
        void ParseLayers(IPsdLayer layer, Size size, GraphicGroup group)
        {
            if (!layer.IsVisible)
            {
                return;
            }

            if (layer.Childreen.Length > 0)
            {
                foreach (var child in layer.Childreen)
                {
                    ParseLayers(child, size, group);
                }
            }
            else
            {
                var graphicPath = ParseLayer(layer, size);

                if (graphicPath != null)
                {
                    group.Childreen.Add(graphicPath);
                }
            }
        }
Ejemplo n.º 31
0
        public bool _isRemapPosOffset_Initialized = false;        //<<Transform과 연결후, 또는 PSD Set Layer의 값으로 부터 초기화가 되었는가

        // Init
        //---------------------------------------------------
        public apPSDLayerData(int layerIndex, IPsdLayer psdLayer, int imageTotalWidth, int imageTotalHeight)
        {
            _layerIndex = layerIndex;

            _name       = psdLayer.Name;
            _isClipping = psdLayer.IsClipping;
            _isBakable  = true;
            //_srcPsdLayer = psdLayer;
            _isClippingValid = true;            //일단 가능하다고 체크

            if (psdLayer.HasImage)
            {
                //1. 이미지 타입의 레이어
                _isImageLayer = true;

                _width          = psdLayer.Width;
                _height         = psdLayer.Height;
                _posOffset_Left = psdLayer.Left;
                _posOffset_Top  = imageTotalHeight - psdLayer.Top;               //좌표계 특성상 반전하자

                _posOffset_Right  = psdLayer.Right;
                _posOffset_Bottom = imageTotalHeight - psdLayer.Bottom;

                _posOffset = new Vector2(
                    (float)(_posOffset_Left + _posOffset_Right) * 0.5f,
                    (float)(_posOffset_Top + _posOffset_Bottom) * 0.5f
                    );

                _opacity            = psdLayer.Opacity;
                _transparentColor2X = new Color(0.5f, 0.5f, 0.5f, _opacity);


                _colorData = new byte[_width * _height * 4];                //W x H x RGBA(4)
                //_colors = new Color[_width * _height];

                int subDataLength   = _width * _height;
                int totalDataLength = imageTotalWidth * imageTotalHeight;

                byte[] colorData_R    = new byte[subDataLength];
                byte[] colorData_G    = new byte[subDataLength];
                byte[] colorData_B    = new byte[subDataLength];
                byte[] colorData_A    = new byte[subDataLength];
                byte[] colorData_Mask = new byte[subDataLength];

                bool isMask = false;

                for (int i = 0; i < subDataLength; i++)
                {
                    colorData_R[i]    = 0;
                    colorData_G[i]    = 0;
                    colorData_B[i]    = 0;
                    colorData_A[i]    = 255;
                    colorData_Mask[i] = 255;
                }


                for (int iChannel = 0; iChannel < psdLayer.Channels.Length; iChannel++)
                {
                    IChannel curChannel   = psdLayer.Channels[iChannel];
                    byte[]   curColorData = null;

                    if (curChannel.Type == ChannelType.Mask)
                    {
                        continue;
                    }

                    switch (curChannel.Type)
                    {
                    case ChannelType.Red:
                        curColorData = colorData_R;
                        break;

                    case ChannelType.Green:
                        curColorData = colorData_G;
                        break;

                    case ChannelType.Blue:
                        curColorData = colorData_B;
                        break;

                    case ChannelType.Alpha:
                        curColorData = colorData_A;
                        break;

                    case ChannelType.Mask:
                        //마스크는 무시한다.
                        curColorData = colorData_Mask;
                        isMask       = true;
                        break;
                    }

                    int dataLength = curChannel.Data.Length;
                    if (subDataLength != dataLength)
                    {
                        //저장되었어야할 데이터와 실제 데이터가 다르다.
                        bool isError = true;
                        if (curChannel.Type == ChannelType.Mask)
                        {
                            isMask = false;

                            //만약 -> Mask의 경우
                            //이미지 전체가 들어올 수는 있다.
                            //확장된 데이터 사이즈와 비교를 하자
                            if (dataLength == totalDataLength)
                            {
                                isError = false;
                                isMask  = true;

                                //데이터가 Height가 거꾸로 되어있다.
                                //X, Y의 오프셋을 적용해야한다.
                                //Debug.Log("Mask Image : Total : " + dataLength + "( " + imageTotalWidth + " x " + imageTotalHeight + " )");
                                //Debug.Log("X : " + _posOffset_Left + " ~ " + _posOffset_Right);
                                //Debug.Log("Y : " + +_posOffset_Top + " ~ " + _posOffset_Bottom);
                            }
                        }

                        if (isError)
                        {
                            Debug.LogError("Data Length is not correct : " + _name + " [ Channel : " + curChannel.Type + " ]");
                            //Debug.LogError("Data Size : " + curChannel.Data.Length + " (Expected : " + totalDataLength + " / Sub : " + subDataLength + ")");
                            //Debug.Log("Mask Image : Total : " + dataLength + "( " + imageTotalWidth + " x " + imageTotalHeight + " )");
                            //Debug.Log("X : " + _posOffset_Left + " ~ " + _posOffset_Right);
                            //Debug.Log("Y : " + +_posOffset_Top + " ~ " + _posOffset_Bottom);
                            continue;
                        }
                    }
                    else
                    {
                        //칼라값을 복사하자
                        Array.Copy(curChannel.Data, curColorData, dataLength);
                    }
                }

                //이제 마지막으로 byte 배열을 만들고 Texture로 구성하자
                int iMainColor = 0;
                int iX         = 0;
                int iY         = 0;
                if (!isMask)
                {
                    //Debug.Log("Image : " + layerIndex + " [ No Mask ]");
                    //마스크가 없는 경우
                    for (int iColor = 0; iColor < subDataLength; iColor++)
                    {
                        //iColor = y * Width + x
                        //RevYColor = ((Height - Y) * Width) + X
                        //iMainColor = iColor * 4;
                        iY         = iColor / _width;
                        iX         = iColor % _width;
                        iMainColor = ((((_height - 1) - iY) * _width) + iX) * 4;
                        _colorData[iMainColor + 0] = colorData_R[iColor];
                        _colorData[iMainColor + 1] = colorData_G[iColor];
                        _colorData[iMainColor + 2] = colorData_B[iColor];
                        _colorData[iMainColor + 3] = colorData_A[iColor];

                        //_colors[iColor] = ByteToColor(
                        //	_colorData[iMainColor + 0],
                        //	_colorData[iMainColor + 1],
                        //	_colorData[iMainColor + 2],
                        //	_colorData[iMainColor + 3]
                        //	);
                    }
                }
                else
                {
                    //Debug.Log("Image : " + layerIndex + " [ Mask ]");
                    //마스크가 있는 경우
                    for (int iColor = 0; iColor < subDataLength; iColor++)
                    {
                        //iMainColor = iColor * 4;
                        //iColor = y * Width + x
                        //RevYColor = ((Height - Y) * Width) + X
                        //iMainColor = iColor * 4;
                        iY         = iColor / _width;
                        iX         = iColor % _width;
                        iMainColor = ((((_height - 1) - iY) * _width) + iX) * 4;

                        _colorData[iMainColor + 0] = GetMaskedColor(colorData_R[iColor], colorData_Mask[iColor]);
                        _colorData[iMainColor + 1] = GetMaskedColor(colorData_G[iColor], colorData_Mask[iColor]);
                        _colorData[iMainColor + 2] = GetMaskedColor(colorData_B[iColor], colorData_Mask[iColor]);
                        _colorData[iMainColor + 3] = GetMaskedColor(colorData_A[iColor], colorData_Mask[iColor]);

                        //_colors[iColor] = ByteToColor(
                        //	_colorData[iMainColor + 0],
                        //	_colorData[iMainColor + 1],
                        //	_colorData[iMainColor + 2],
                        //	_colorData[iMainColor + 3]
                        //	);
                    }
                }

                _image = new Texture2D(_width, _height, TextureFormat.RGBA32, false);
                //_image.SetPixels(_colors);
                _image.LoadRawTextureData(_colorData);
                _image.wrapMode = TextureWrapMode.Clamp;
                _image.Apply();
            }
            else
            {
                _isImageLayer = false;

                _image     = null;
                _width     = 0;
                _height    = 0;
                _colorData = null;

                _width          = psdLayer.Width;
                _height         = psdLayer.Height;
                _posOffset_Left = psdLayer.Left;
                _posOffset_Top  = imageTotalHeight - psdLayer.Top;               //좌표계 특성상 반전하자

                _posOffset_Right  = psdLayer.Right;
                _posOffset_Bottom = imageTotalHeight - psdLayer.Bottom;

                _posOffset = new Vector2(
                    (float)(_posOffset_Left + _posOffset_Right) * 0.5f,
                    (float)(_posOffset_Top + _posOffset_Bottom) * 0.5f
                    );

                _opacity            = 1.0f;
                _transparentColor2X = Color.black;
            }

            _posOffsetLocal = _posOffset;

            _parentLayer = null;
            _childLayers = null;

            _isRemapSelected   = false;
            _remap_TransformID = -1;

            _remap_MeshTransform      = null;
            _remap_MeshGroupTransform = null;

            _remapPosOffsetDelta_X        = 0;
            _remapPosOffsetDelta_Y        = 0;
            _isRemapPosOffset_Initialized = false;

            //추가 : GUI를 위해서 랜덤한 색상을 정하자
            MakeRandomGUIColor();
        }