Hi, its late, so please excuse any typos.
I’ve been stuck on this problem for about 6 hrs and I am running out of ideas. Have been on the unity answers forum all night, trying to find out whether this is an issue…
Essentially I am dynamically/programmatically creating 54 planes that are essentially square tiles.
They are children of a parent object and inherit the position and rotation from the parent object.
Then, using a simple loop, I populate each plane/tile with a dynamic texture using the WWW class to download the image and load it into the plane’s main texture.
Source image for each tile is 128*128 PNG. (about 15-20k, not huge…)
Works well, and can rotate the parent object and child planes follow suit… all good.
BUT!!!
I can then try repopulate the SAME tiles (no destroying, just reassigning new textures to them) a few times, before it consistently crashes out after about the 3rd or 4th time of loading the new set of images, but when running in the editor it seems to slow down more and more each time I repopulate the tiles with new images (however it can be done about 50 times in the editor, rather than just the measly 3 times on the device.
The obvious things I am doing are:
Destroying the WWW object each time I download the image.
Setting any variables to Null and destroying what I can after each time the tiles are updated.
Using the same tiles, and not destroying and recreating, to save potential memory leaks.
Doing a Garbage collection after each reload of the images.
Like I said, I have spent many hours trying to resolve this – I can provide code samples, but I wanted more to ask whether there are any “quirks” that anyone is aware of related to this?
I am just reloading new texture images, to existing planes, from the local file storage, and all of the images are the same size, (about 15k each!!) and just looping through the 54 planes and setting the main texture to the www.texture of the downloaded PNG.
I have tried also destroying the planes, and recreating, and the same problem occurs. 3 or 4 times of loading sets of images, and it just crashes out — works fine in the editor.
I guess I dont understand, if I am essentially just replacing the existing textures, with new ones that are comparable in size, it should not increase the memory/resource usage, I wouldn’t have thought? But it appears to be?
Should i be doing something to the main texture of the plane before asssigning a new texture image?
Any ideas? Thankyou in advance.
I’m using Unity Iphone edition