Hi,
I’m currently facing a odd bug with Unity when I load PNG files with “LoadImage” method.
What I do is the following:
- create a Texture2D
- “LoadImage” file with a path
- Save texture2D in a file with “EncodeToPNG” and “File.WriteAllBytes” methods
Everything works well with 24b PNG files with or without alpha transparency (the original file loaded is the same as the saved texture2D).
But as soon as I try to load a 8bit PNG file with or without alpha transparency, Unity gets a weird texture and save that weird texture to PNG as well. The original file is not at all like the saved texture2D…
What I get is something semi-transparent (even when there is no transparency in original file) with purple/pink colors.
See this screenshot:
On the left, what Unity gets after loading file and/or saving texture
On the right the original file that Unity should load