示例#1
0
        public virtual void CutOutSpriteFromTexture2D()
        {
            x = index % width * sWidth;
            y = index / width * sHeight;

            tmpPixels = tex.GetPixels(x, y, sWidth, sHeight);
        }
示例#2
0
        public virtual void IndexColors()
        {
            //Debug.Log("Index Colors");
            // Get the total pixels from the texture
            var pixels = tex.GetPixels();

            totalPixels = pixels.Length;

            width = tex.width;

            currentStep++;
        }
        public void ParseFlagColors()
        {
            var newFlagColors = new List <string>();

            if (flagTex == null)
            {
                newFlagColors = flagColors.ToList();
            }
            else
            {
                var pixels = flagTex.GetPixels();

                var total = pixels.Length;

                for (int i = 0; i < total; i++)
                {
                    var color = pixels[i];
                    var hex   = ColorData.ColorToHex(color.r, color.g, color.b);



                    if (color.a == 1f && !Equals(color, maskColor))
                    {
                        if (newFlagColors.IndexOf(hex) == -1)
                        {
                            newFlagColors.Add(hex);
                        }
                    }
                }
            }

            flagColorChip.RebuildColorPages(newFlagColors.Count);

            for (int i = 0; i < newFlagColors.Count; i++)
            {
                flagColorChip.UpdateColorAt(i, newFlagColors[i]);
            }

            currentStep++;
        }
示例#4
0
        protected virtual void CopyPixels()
        {
            // Need to make sure we have colors to copy over
            if (colors != null)
            {
                var pixels = texture2D.GetPixels();

                var total = pixels.Length;

                for (var i = 0; i < total; i++)
                {
                    var refID = pixelData[i];

                    if (refID > -1 && refID < total)
                    {
                        pixels[i] = colors[refID];
                    }
                }

                texture2D.SetPixels(pixels);
            }

            currentStep++;
        }