- Home /
Materials disappear randomly on Android
I have a problem with the Android version of my game, where some materials or textures don't appear in a scene. This happens completely randomly: when I build the game again without changing anything, it's some other materials that are missing. And the gameobjects don't show a magenta material, they just don't show at all as though they had completely transparent material. It looks like that the missing materials are dependent on the particular build: the same materials are always missing in the same scenes even if I reload the scenes.
The shaders I'm using are Particles/Alpha Blended (the game is a 2D game).
What android device are you exporting to? What version of Open GL? I recently discovered bugs in an app that were caused on newer devices (specifically Adreno 225 GPUs) if they ran with GL ES 1.1 or older. Although they should be backward compatible, I seriously doubt they tested with that version. Textures were missing, just white in their place. The problem went away by moving to GL ES 2.0. It doesn't explain why you would see differences after a build.
After more testing I have now noticed that I was mistaken about the missing materials being dependent on the build or being always the same even during a single run of the game.
It seems that in the first 2-3 loaded scenes everything looks fine but then some materials start to disappear. I'm starting to think that it might be an issue of running out of memory since I use pretty many big (2024x2024) unpacked textures as pixel perfect sprite sheets. But I don't get why materials loaded in previous scenes won't get unloaded.
And answering to supernat's questions:
The device is Samsung Galaxy S Plus (GT-I9001). And I'm using OpenGL ES 2.0 already.
I resized all my textures from 2048x2048 to 512x512 and no textures seemed to go missing anymore. I just wonder why it seems like unused resources aren't unloaded when a new level is loaded. I even tried adding Reources.UnloadUnusedAssets() to start of every level but it didn't help (and somebody told that loading levels should call this anyway http://answers.unity3d.com/questions/163434/unloading-unused-assets-automatically.html). It would be great to be able to use the current textures, resizing them might be quite a lot of work.
Answer by Hemaolle · Sep 15, 2013 at 08:54 AM
All right, now I seem to have found a good solution. It was changing the texture format from texture import settings from ARGB 32 bit to Automatic Compressed. The quality seems pretty good still and no textures disappear any more.
Later I managed to find an even better solution where I manually unloaded the textures using Resources.UnloadAsset(texture). After this I didn't even need to compress them.