- Home /
Is there a way to free the memory duplication of textures loaded at runtime?
I need to load textures at runtime that have never seen the unity editor. That means I can't use asset bundles.
The option I have seems to be Texture2d.LoadImage(). I've noticed that all of those images are "readable" and also that memory usage is very high. How can I avoid this extra memory ding of keeping all my textures on main memory?
textures are not on the CPU. they are in your memory. using is readable enabled will double the memory usage but has nothing to do with the CPU. also it don't use GPU unless you use Getpixels and ...
I'm well aware of this. By CPU I meant main memory ins$$anonymous$$d of graphics memory. I'll fix this.
Answer by jonas-echterhoff · Feb 09, 2010 at 09:26 AM
It is currently not possible to set runtime generated textures as non-readable. While such a feature would be technically feasible, it is not a common use case, as people don't typically generate huge amounts of textures dynamically. Why do you need to do this? Possibly there is a better way to get the same results. Is texture memory usage actually an issue you are running into?
In nearly every game, $$anonymous$$imum texture usage is a requirement. Our game has many many different textures that need to stay as small as possible.
I need to do this because new character equipment textures are downloaded from the server at runtime, and uploaded to the server at runtime.
Additionally, content creators do not use Unity.
It should be feasible, and I expect that there is a way to handle this in a thread safe manner if I were to create my own threading. I'm just not sure how yet and wonder if anyone has a tip or two.
Answer by Ashkan_gc · Apr 15, 2010 at 07:39 PM
currently it's not possible to make textures unreadable but you can compress them using compression libraries or even pack them in zip files and extract them at runtime. search the net for "compression library for mono". i should remind something: you can not call unity libraries in threads other than the main thread