Right now I am using following code to load textures from files in my game(and I want to load them like this):
var bytes = File.ReadAllBytes(AbsolutePath);
var texture = new Texture2D(1, 1,TextureFormat.ARGB32,false);
texture.LoadImage(bytes);
The thing is that this texture has transparent regions and they become black after loading texture. How can I load partially transparent texture using Texture2D.LoadImage?
@Olmi Unity say that this pixel is RGBA(0.000, 0.000, 0.000, 1.000), I tried with one that was RGBA(0.000, 0.000, 0.000, 0.000) and both of them are black ingame
Well, if the image data is correct,it should show up. But that depends also on your shader.
I just tried loading my test png from disk and it does show up correctly when I apply that image as a sprite.
I used code like this:
var bytes = File.ReadAllBytes(AbsolutePath);
var texture = new Texture2D(1, 1,TextureFormat.ARGB32,false);
texture.LoadImage(bytes);
Sprite sprite = Sprite.Create(texture, new Rect(0,0,texture.width, texture.height), new Vector2(0,0));
GetComponent<SpriteRenderer>().sprite = sprite;
Result looks like this:
But I’d definitely also check the image and try some other tool/plugin for saving like SuperPNG in Photoshop. I think @bgolus has suggested it too sometime in the past as a good option, if I remember correctly.