Hi,
Recently we start worked on a quite big project that needs a lot of resources to be instantiated at run time. Talking about 2GB of .fbx
So, I had to write some editor scripts in order to collect data and build a kind of run-time level streamer.
Beside the fact that I run out memory so many many many times, I noticed that Unity doesn’t seem to unload resources even they are not longer used. Most of all, AssetDatabase doesn’t seem to have a good way to unload resources, presumibly references by Unity internally. This forced me to put our assets into the Resources folder, where I could load assets from, and try to free some memory with Resources.UnloadAsset(), or UnloadUnusedAssets(). These two function don’t seem to affect memory allocation though, at least within the editor environment.
Most of all, I had to remove all those assets from the Resources folder because Unity take them into account when you build the project, resoulting in a predictable OOM. Again Unity seems not to scale well when manages a large number of resources. Not even on procedures that are “natively” supported, such the Build pipeline.
I fixed this by splitting collection of assets into several scenes,that could be loaded at runtime with Application.LoadAdditiveLevelAsync call.
My question is though:
Are all these issues well known? Or there is a better and more efficent way (in terms of memory consumption) to manage a large number of assets?
Why assets into the Resources folder are not loaded-baked(processed-whatever)-unloaded during the building process? Doesn’t this force the user to have a limited number of Resources loadable at runtime?
Any suggestion or advice will be much appreciated.
P.S. I know the AssetBundle would fix the run-time problem (although increase the producion time spent in the editor pipeline), but you still have these issues when loading assets from the editor with custom scripts.
Thanks,
Fabio