It worked fine. Upon upgrading to 5.1, however, that produces a color-shifted image - the PNG isn’t being loaded correctly. I attempted to work around that by doing this:
That worked inside the editor, but on an iPad, it still showed the color shifted/corrupted image.
I proceeded to try every single TextureFormat available, and not a single one of them solved the problem on the iPad. Unfortunately, storing the image in Resources is not an option, because they’re actually downloaded from a server and store in Documents on the device.
I urgently need an answer or a fix for this, because if I can’t get one I’m going to be stuck having to roll back to Unity 5.0.3 permanently for this project.
Not an area I have played with. This might sound strange, but are you sure the texture loading is faulty? Maybe the texture loads just fine, but the RawImage rendering of it messed it up? A quick look over the docs shows that there is a material used for rendering. Dump out the texture once you’ve loaded it, I guess by using EncodeToPNG and writing the bytes out to disk. Check that and if it’s color shifted then the loading is faulty. If it looks okay, then assume somethings going wrong with the material/rendering.
The first part you saw. The second part starting with GameObject plane2 makes the same image as the texture of a created mesh plane (there’s another function called CreateMesh that makes it). That image looks the same as the one in the RawImage.
Third part does as you suggested, exports the imported image as a png. It took looks just like the first two images:
Note that this issue only occurs with png’s that have transparency. I tried it with a non-transparency png and it looks fine.
I’m also running into this problem. Also seeing different results from 5.0 in regards to whether or not textures loaded at runtime display correctly in linear color space, for both pngs and jpegs. Going to look into it a bit more and see if I can locate the exact problem.
Using the overloaded constructor of Texture2D to explicitly mark the texture as linear seems to have done the trick with the linear color space issues I was having. Had to change a couple of my Image processing functions to no longer convert the texture to sRGB as well.
Still having issues with transparent pngs. Important to note is that pngs that I saved out with EncodeToPng prior to updating from 5.0.2p3 to 5.1.1f are still displayed correctly when loaded. Only textures saved out with EncodeToPng in 5.1.1f seem to have the issue.
I have the same problem. Pngs uploaded from server and created in 3d party software (actually i don’t know where). and most of images are wrong
original file:
in unity:
sorry. just checked release notes on 5.1.1p2 and sims it fixed there