- Home /
Loading images fails on Android for existing Texture2Ds.
Hi all,
I think I'm encountering a Unity bug but just wanted to post it here before I go reporting it.
I was having an issue in an app I'm working on where some images, loaded from an external file, would show on screen as a red question mark when I know the image should work fine.
I made a smaller app to test the issue and have attached it here. Basically the issue is that if I have a Texture2D and I call .LoadImage on it, that will work, but if I then call .LoadImage again to load new image data that will return true (as though it worked) but only show the red question mark.
This only seems to happen when running on an Android device. In some cases I can get around it by calling .LoadImage twice in a row to load the same image, or by creating a new Texture2D and loading into that instead. However I don't want to do either of those things as they noticeably slow down my app.
In the attached project I have two images which load new Texture data each time the screen is tapped/clicked. The only difference between them is that one creates a new Texture2D each time and the other does not.
Does anyone have any suggestions?