How to create and use Asset Bundles - piotrulos/MSCModLoader GitHub Wiki
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)
-
Unity 5.0.0f4 (32-bit) or (64-bit) (current unity used in game, kinda old but still can download from archive, go to unity 5.x and scroll all way to bottom) or use Direct Link
NOTE: The old unity licensing system is broken, you first need to install unity 5.6.7f1, then launch it directly (from desktop shortcut, not unity hub) and go through the license activation, then create a project and open it. Then you should be able to use 5.0.0f4. - Download
MSC_AssetBundle_Template.unitypackage
file from Releases
- Install unity 5.0.0
- Create new Project
- Double-click
MSC_AssetBundle_Template.unitypackage
and import it to your project - Create some prefab (with everything you need, complex objects, animations, etc.)
- Select created prefab, and on bottom left you should have AssetBundle
- Click on first
None
and selectNew...
- Name it for example
something.unity3d
and press enter
- Add more things (prefabs,textures,sounds) that you need by just selecting "None" and then name of your bundle
something.unity3d
- If you are done, press anywhere right mouse button, or from top menu select
Assets
and clickBuild AssetBundles
- Wait to finish, and go to your project root folder (you can go there by
right click>Show in explorer
)
- Go to folder called
AssetBundles
and grab your filesomething.unity3d
this is file you only need (ignore other files)
- 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.