Appearance
Asset Bundles
Introduction
Asset Bundles are files that contain unity assets like sprites, audio and more.
Custom charms, weapons, levels, and most of Blender's features use them in a way.
Creating them requires installing Unity v2017.3.0.
Set up the project
INFO
This is a one time process, you won't have to do it again.
- In the unity hub, create a new 2D project and open it.
- Create
Scripts\Editor
directories inside of your project'sAssets
. - Inside of the
Editor
directory, create a script calledBundleGen
that will contain the following code:
cs
using UnityEngine;
using UnityEditor;
using System.IO;
public class BundleGen
{
[MenuItem("Assets/Generate Bundles %G")]
private static void GenerateBundles()
{
string dirPath = "Assets/StreamingAssets";
if (!Directory.Exists(Application.streamingAssetsPath))
Directory.CreateDirectory(dirPath);
BuildPipeline.BuildAssetBundles(dirPath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
}
}
Creating the assets
- Bring your asset to
Assets
if it isn't there already. Click on the asset to view it in the inspector: - In the bottom of the inspector, click on the
AssetBundle
dropdown and click onNew
to name your new bundle. - You can add all of the assets you want to the new bundle, and then use the shortcut
Ctrl+G
to generate your bundles. - Go to your project in file explorer and go to the
Assets\StreamingAssets
directory, you can now grab the generated asset bundle. - Go to the directory where your mod is installed and create a new
Assets
directory in there, put the asset bundle there.