示例#1
0
 public static void ProcessTexture_Clean(SWTexture2DEx tex)
 {
     SWUndo.RegisterCompleteObjectUndo(tex);
     Color[] colors = new Color[tex.width * tex.height];
     tex.SetPixels(colors);
     tex.Apply();
 }
 public override void AfterLoad()
 {
     base.AfterLoad();
     if (texture != null)
     {
         var colorful = texture.GetPixels();
         for (int i = 0; i < colorful.Length; i++)
         {
             if (data.maskChannel == SWChannel.r)
             {
                 colorful [i] = new Color(0, colorful [i].r, 0, colorful [i].r);
             }
             if (data.maskChannel == SWChannel.g)
             {
                 colorful [i] = new Color(0, colorful [i].g, 0, colorful [i].g);
             }
             if (data.maskChannel == SWChannel.b)
             {
                 colorful [i] = new Color(0, colorful [i].b, 0, colorful [i].b);
             }
             if (data.maskChannel == SWChannel.a)
             {
                 colorful [i] = new Color(0, colorful [i].a, 0, colorful [i].a);
             }
         }
         texMask.SetPixels(colorful);
         texMask.Apply();
     }
 }
示例#3
0
        public override void AfterLoad()
        {
            base.AfterLoad();
            if (texture != null)
            {
                if (data.resolution != texture.width)
                {
                    data.reso = (SWTexResolution)SWDataNode.resoList.IndexOf(texture.width);
                    ResetMask();
                }

                var colorful = texture.GetPixels();
                for (int i = 0; i < colorful.Length; i++)
                {
                    if (data.maskChannel == SWChannel.r)
                    {
                        colorful [i] = new Color(0, colorful [i].r, 0, colorful [i].r);
                    }
                    if (data.maskChannel == SWChannel.g)
                    {
                        colorful [i] = new Color(0, colorful [i].g, 0, colorful [i].g);
                    }
                    if (data.maskChannel == SWChannel.b)
                    {
                        colorful [i] = new Color(0, colorful [i].b, 0, colorful [i].b);
                    }
                    if (data.maskChannel == SWChannel.a)
                    {
                        colorful [i] = new Color(0, colorful [i].a, 0, colorful [i].a);
                    }
                }
                texMask.SetPixels(colorful);
                texMask.Apply();
            }
        }
示例#4
0
        public static SWTexture2DEx TextureResize(Texture2D tex, int newWidth, int newHeight)
        {
            SWTexture2DEx newTex = SWCommon.TextureCreate(newWidth, newHeight, TextureFormat.ARGB32);
            var           colors = TextureResizeBase(tex.GetPixels(), tex.width, tex.height, newWidth, newHeight);

            newTex.SetPixels(colors);
            newTex.Apply();
            return(newTex);
        }
示例#5
0
//		public static SWTexture2DEx TextureCopy(SWTexture2DEx f)
//		{
//			SWTexture2DEx t = TextureCreate (f.width, f.height, f.format, f.alphaIsTransparency);
//			var colors = f.GetPixels ();
//			for(int i =0;i<colors.Length;i++) {
//				colors[i].a *= 0.6f;
//			}
//			t.SetPixels (colors);
//			t.Apply ();
//			return t;
//		}

        public static SWTexture2DEx TextureCreate(int w, int h, TextureFormat format)
        {
            SWTexture2DEx t = new SWTexture2DEx(w, h, format, false, false);

            t.filterMode = FilterMode.Trilinear;

            var colors = t.GetPixels();

            for (int i = 0; i < colors.Length; i++)
            {
                colors [i] = new Color(0, 0, 0, 0);
            }
            t.SetPixels(colors);
            t.Apply();
            return(t);
        }
示例#6
0
        /// <summary>
        /// Resize for editing
        /// </summary>
        public static bool TextureResize(SWTexture2DEx tex, int size)
        {
            if (size != tex.Texture.width)
            {
                var cs   = tex.Texture.GetPixels();
                var oldW = tex.width;
                var oldH = tex.height;

                var colorsNew = TextureResizeBase(cs, oldW, oldH, size, size);
                tex.Texture.Resize(size, size);
                tex.SetPixels(colorsNew);
                tex.Apply();
                return(true);
            }
            return(false);
        }
示例#7
0
        public static SWTexture2DEx TextureResize(Texture2D tex, int newWidth, int newHeight)
        {
            SWTexture2DEx newTex       = SWCommon.TextureCreate(newWidth, newHeight, TextureFormat.ARGB32);
            var           colorsOrigin = tex.GetPixels();
            var           colors       = newTex.GetPixels();

            for (int i = 0; i < newWidth; i++)
            {
                for (int j = 0; j < newHeight; j++)
                {
                    Vector2 uv    = SWTextureProcess.TexUV(newWidth, newHeight, i, j);
                    int     index = TexUV2Index(newTex.width, newTex.height, uv);
                    colors[index] = SWTextureProcess.GetColor_UV(tex.width, tex.height, colorsOrigin, uv);
                }
            }
            newTex.SetPixels(colors);
            newTex.Apply();
            return(newTex);
        }
 protected override void MissionEnd()
 {
     base.MissionEnd();
     tex.SetPixels(texColorBuffer);
     tex.Apply();
 }