Is it possible for a texture to exist in memory if it is not associated with any material in scene? My question, is in reference to swapping out textures after run time.
Yep, simply include it in a “Resources” folder somewhere in your project. Another way is to have a reference to it on an script somewhere, and to pass around the reference as needed.
I am actually wondering, about garbage collection.
If I have texture x on material x at start, but then swap out texture x for texture y, now, texture x is not on any material, is texture x deleted from ram?
It will be garbage-collected, but only if NOTHING references it. If your script holds a reference to material X that still references texture X, texture X will still be in memory.
Ah,
Thank you.
So any way you can user Resource.UnloadAsset(Object asset) to force texture to unload. You can do some tricks with it. For example when you unload some asset like mesh or texture, you still have reference on it, and if you try to read some data from it, engine will load it to memory again. Its can be useful on mobile devices with low memory on the board…
Right, thank you.