AssetBundle confusion

Hi All,

I’ve searched and tried for a while but to no avail so I will post here hopefully I can make this clear and get some help!

I’ve got an MMORPG game and is already in production running nicely, but there are some big changes I want to do and I’ll explain.

The game has lots of cool items(armor, weapons, food, etc). All of these items are prefabs that are stored in the Resources folder. These items are instantiated dynamically when needed, e.g. when a some other players enter your room and they’ve got “A Big Sword” in their hands, the game knows to load “A Big Sword” from the Resources folder by name and bam he’s got a big sword. Same goes with all the armors and character customization, and shops, etc, etc.

This loading from Resrouces folder is fast, and the game needs it to be fast, because if the dood all of a sudden decides he’s gonna take out a shield it has to be immediate, and loading by name with Resources folder works good that way.

So everything is great about this setup, except for one thing. Everytime I want to add just a single new item to the MMO I’ll have to release a new build. So I’m now venturing into AssetBundles territory and I’m not sure if it’s the right solution and I really need clarification on how it works.

Is there anyway that I can at the start of the game use WWW.LoadFromCacheOrDownload to get all the prefabs I need, but not have them loaded in memory but just stored to disk so that I can instanciate any objects by name as how I did it with resources?

I have read some people advice to store each prefab as a separate asset bundle, but is that going to achieve the same thing I need?

So to sum up, here is the main question:

  • How do I stream prefabs from a server and store to disk so I can use it the same way I use Resources loading by name?

Isn’t that already how asset bundles work? Have you seen the AssetBundle.Load() method?

www.assetBundle.Load( "asset name" );

Is equal to:

Resources.Load( "asset name" );

What’s the problem?

The problem is www.assetBundle that holds my prefabs are stored in RAM. Most cell phones are not able to hold all my prefabs in RAM. Resources works because they are on disk and I can just retrieve them in a snap and they don’t take up RAM.

If I have 1 asset bundle per prefab it will probably solve the RAM problem, but then now I gotta stream the prefab to the machine(phone) everytime the prefab is needed, and that’s not good. I need a way to get the asset bundle’s data onto disk and then load those prefabs by name on demand without network traffic and without storing all the prefabs in RAM.

use the www class to download the asset bundle. dont load it into ram once its downloaded, but save the bytes to disk (as an asset bundle file). You can also load it into mem and save it to disk at the same time, its up to you.

Now you can load them with the asset bundle call, but instead of grabbing the bundle from http://www.yourgame.com/assetBundle1.unity3d you will load it file://sdcard/mygame folder/dlc/assetBundle1.unity3d

this is how we do it now, but we still have the issue with asset bundles themselves, as i don’t like using them because loading and unloading them is a PITA and we cant share asset bundles between different platforms.

thx! Do you have code examples. Also when you load file://sdcard/mygame folder/dlc/assetBundle1.unity3d, does it not still put that whole bundle in RAM?