I'm trying to build unity player as small as possible, so I decided to put all assets into a asset bundle and keep only levels with scripts in main application.
I have successfully created both application and bundle, but I'm stuck on loading only required assets for a single level.
What I'm doing now is loading all assets from bundle at application startup and mark them by DontDestroyOnLoad, so they are kept in memory when a level is loaded. While this is hardly final solution, I'm looking how to load only assets needed for a particular level, preferably without much hassle.
So I'm looking for a way how load a level and let Unity to load and instantiate required assets from asset bundle, just as they were part of the application.
Is this possible? Or do I need to do it a hard way? (i.e. to generate list of required assets and manage their loading and unloading manually for example)
Thanks in advance!
asked Mar 15 '11 at 12:37 PM
first of all if you load something from asset bundle you can cache it in new versions and even without caching they will remain in browser's cache at least in current session so redownload will not happen and you don't need to keep track of them.
why don't you use streamed web players? just check the box called streamed in web player build and then unity will load levels one by one with their required assets. you can load downloaded levels and let the user play the game while downloading next levels. it's easy and is exactly what you want. at first all headers/scripts/ will be downloaded with the first scene assets. then the player starts playing while downloading second scene and so on.
if you are using a platform other than web player unfortunately there is not an easy way to do that. you should create an asset bundle of all required assets in a level and use AssetBundle.LoadAll to load them all when download is complete.