EtG Modding Guide
Search…
⌃K

Making Asset bundles

Difficulty: 5/10

Making asset bundles are a way to use real prefabs in gungeon.

Creating Asset Bundles

You need to download unity and download version 2017.4.40 so that the asset bundles you make are compatible with gungeon.
They can be located here:
Create a new folder called Editor:
And inside the floder create a c# script and call It CreateAssetBundles. To do this right click and select create>C# script
Now open the script and paste this code in:
using UnityEngine;
using UnityEditor;
using System.IO;
using UnityEngine.UI;
public class CreateAssetBundles
{
[MenuItem("Assets/Build AssetBundles")]
static void BuildAllAssetBundles()
{
string assetBundleDirectory = "Assets/StreamingAssets";
if (!Directory.Exists(Application.streamingAssetsPath))
{
Directory.CreateDirectory(assetBundleDirectory);
}
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
}
}
Go back to the assets folder and create a new folder called BundledAssets, this will contain all the gameobjects, textures, etc. select the object you want to be part of the asset bundle and go to the bottom of the inspector panel
create a new assetbundle
and then any object you want in the assetbundle will go under the one you made.
click the assets tab at the top left and go to the bottom where it says build assetbundles.

Loading the AssetBundle

in your mod drop this file in.
AssetBundleLoader.cs
2KB
Text
in your module add public static AssetBundle ModAssets;
before you load anything from this asset bundle do ModAssets = AssetBundleLoader.LoadAssetBundleFromLiterallyAnywhere("assetbundlename");

Loading objects from the AssetBundle

to load an object use ModAssets.LoadAsset<ObjectType>("object name");
for example, if it's a gameObject use
ModAssets.LoadAsset<GameObject>("object name");