I just updated a project to Unity 3, and now LoadImage doesn’t work. All the assets are there, all the variables are set correctly in the Inspector, and nothing in the script has changed. Here’s the code:
var originalImage: Texture2D;
var imageAssets: TextAsset[];
originalImage.LoadImage(imageAssets[currentSelection].bytes);
Now the original image turns into an 8x8 red question mark. Does this work differently in Unity 3?
If it’s the same error as here: http://forum.unity3d.com/threads/63903-deriving-from-gameobjet-not-possible-(
(Error near the bottom of the first page)
Then it has to do with accessing an external site. Unity 3 has new Security features. Check out the link I posted at the end of that thread for how to setup allowable domains.
“If you’re using the text asset to contain binary data, you should make sure the file has the .bytes extension. For any other of the extentions the TextImporter will try to strip nonascii characters if it is unable to parse the file as an utf8 string.”
Yes, but the script reference for LoadImage says to use the .txt extension, which is what I have been doing. But then in the example, it shows the .bytes extension. Doesn’t matter, either .txt or .bytes gives me the red question mark.
Is LoadImage just broken in Unity 3? This worked, with files with the .txt extension, before updating the project. This is really a MAJOR problem, as my app i useless if I can’t load the images. I was supposed to send this finished app to a publisher to review last week, and now I can’t even get it to build a working app. Is my only solution to try to convert my app back to an older version of Unity?
load image is not broken, it just eats 10-15 times as much memory as it should.
the only thing that does not make sense here is that you use textassets for texture storage if you can use textures directly (eats less space), because you aren’t getting anything when storing them like this in the shared bundles. and from external, WWW.texture works
Could you please explain this. Are you saying it doesn’t work because it uses too much memory? But it didn’t in version 2? And that making these textures readable takes less memory than using LoadImage?
I used text assets because I had too many large textures, and the app would not run on iPad. I don’t need the textures per se, just their pixel data for calculations. Can you suggest a better way to store the pixel data from over 20 256 x 256 uncompressed 24-bit images? They can’t be compressed because I need the actual pixel data. And they are not external – I don’t want to have to put the images on a server somewhere then require the user to have a WiFi connection.