Asset Bundle
Last updated
Last updated
Asset Bundle
We put all of our game assets except for scripts in the assetBundle and download it at runtime. The size of the assetBundle should not exceed more than 15 mb. Please make sure to use proper compression techniques on assets to reduce the size of assetbundle. The lesser the size the better the performance of your game.
There are two ways to create asset bundle.
1. Prefab based asset bundle.
2. Scene based asset bundle.
Prefab based Asset Bundle In this approach we create one prefab of a complete game and put that prefab in an asset bundle. During gameplay we load that prefab from the bundle and instantiate it in an empty scene. This approach is good for small 2D games as shaders and lighting are not used much. Steps to create prefab based asset bundle:
Create an empty GameObject, name it MainParent and then drag all the gameobjects as children of this GameObject. Make sure that the reference of all the assets that are being used in the game are present in the MainParent.
Create another empty GameObject and name it TutorialParent if your game has an interactive tutorial. (For more details goto Interactive Tutorial section)
Create a folder named AssetBundle. Make prefabs of these two GameObjects (MainParent and InteractableTuts) in the same folder. Next, give an asset bundle tag (with your game name) to the folder. Now, the bundle will be created by right clicking on the project window.
Scene based asset bundle
In this approach we put the scene in asset bundle and load the scene from asset bundle at runtime. This is generally good for 3D games where lighting, skybox and shaders are heavily used. We put the asset bundle tag to the scene and create the asset bundle. Scene name should be “Game”. To create the asset bundle for the approach, Steps are similar to a prefab based approach. 1. Put the asset bundle tag to the scene. 2. Rest is similar to a prefab based approach. Just keep things in Scene like Keeping in “MainParent” prefab in prefab based.
Key points to note before creating asset bundle
Every asset other than scripts must be referenced from the assetbundle and will be downloaded at run time.
If you have multiple scenes in your game, please find a way to load those scene objects into one assetbundle since we have only one scene for the game to run.
If you have multiple levels in your game, you can make prefabs of them and store them in the assetbundle and load one level at a time. WinZO will provide an input with which level to load before the game starts and then load that level from the assetbundle.