Skip to content

How to create and use Asset Bundles

piotrulos edited this page Mar 15, 2023 · 8 revisions

Asset bundles allow you to import unity prefabs into you mods, this will save you some time for more complex objects.

This tutorial is only how to create and import asset bundles, if you want some tutorial for unity engine itself, this is not place for you.
Best way to start with unity is official documentation (click here for version 5.0)

What do you need?

Let's start

  • Install unity
  • Open prepared project you downloaded in previous step.
  • Create some prefab (with everything you need, complex objects, animations, etc.)
  • Select created prefab, and on bottom left you should have AssetBundle
    prefab
  • Click on first None and select New...
    ab
  • Name it for example something.unity3d and press enter
    ab
  • Add more things (prefabs,textures,sounds) that you need by just selecting "None" and then name of your bundle something.unity3d
    ab
  • If you are done, press anywhere right mouse button, or from top menu select Assets and click Build AssetBundles
    ab
  • Wait to finish, and go to your project root folder (you can go there by right click>Show in explorer)
    ab
  • Go to folder called AssetBundles and grab your file something.unity3d this is file you only need (ignore other files)
    ab
    ab
  • Copy this file to your mods Assets folder and import it in code
AssetBundle ab = LoadAssets.LoadBundle(this,"something.unity3d");
GameObject go = ab.LoadAsset<GameObject>("test.prefab"); 
//REMEMBER to instantiate your object next.
ab.Unload(false); //unload when you take all items you need.

More options of how can you load AssetBundles

Clone this wiki locally