- Home /
Lazy Loading and Unloading of prefabs?
So we've got an Android game that has a ton of small levels all of which are currently represented by prefabs, and the problem is that if every level is loaded into memory at once, we run out of memory on device. We have a custom asset that contains a gameobject array of all the levels in order, and we had hoped that prefab and asset references were lazy loaded, but sadly they are not - the moment a scene with a reference to the custom asset containing the list is loaded, Unity loads both the list itself and every level prefab in the list into memory.
So my questions are what process are others using with iOS/Android in order to have:
A) objects that can be loaded at runtime only when actually needed
B) objects loaded at runtime can be unloaded
C) ordered lists of the objects to be loaded this way that can be accessed without forcing all objects to be loaded
D) a build process that ensures that every object in the ordered lists got put in the build, and that only objects referenced by the lists got put in the build
I've seen the page here: http://unity3d.com/support/documentation/Manual/Loading%20Resources%20at%20Runtime.html which mentions assetbundles and resources folders, which look like they give A & B - the part I don't see is the best way to achieve C & D - namely what do you guys do for the list of assets and dependency checking - lists of strings and BuildPipeline scripting? Any smart tricks or features of Unity that help here that I am missing? An way to just have a lazily loaded and unloadable prefab reference outside of assetbundles and resource folders?
thanks