When I am using it I want that remaining pixels would be completely transparent. However, they are grey coloured. How could I change alpha values that pixels would get transparent.
My proposal as a static class public static Texture2D FillColorAlpha(Texture2D tex2D, Color32? fillColor = null) { if (fillColor ==null) { fillColor = Color.clear; } Color32[] fillPixels = new Color32[tex2D.width * tex2D.height]; for (int i = 0; i < fillPixels.Length; i++) { fillPixels = (Color32) fillColor;}tex2D.SetPixels32(fillPixels);return tex2D;}
I know this is a super old post, but I am having the same problem even after pre-filling a Texture2D with completely transparent (and black) pixels. I was also sure to specify the TextureFormat (in this case as RGBA32 as I will be adding pixel data to it later from other textures in that format). At this point though, it’s just a generic Texture2D with completely transparent pixel data and it’s rendering as semi-transparent white.
Thanks, that's wonderful. I didn't knew that transparency is property of color.
– chanfortMy proposal as a static class public static Texture2D FillColorAlpha(Texture2D tex2D, Color32? fillColor = null) { if (fillColor ==null) { fillColor = Color.clear; } Color32[] fillPixels = new Color32[tex2D.width * tex2D.height]; for (int i = 0; i < fillPixels.Length; i++) { fillPixels = (Color32) fillColor; } tex2D.SetPixels32(fillPixels); return tex2D; }
– cyanUNITY