Export a Vehicle Model in an Asset Bundle - NeisesMike/VehicleFramework GitHub Wiki

Get the Right Version of Unity Editor

You should prepare your AssetBundle in a Unity Editor which matches the version used to build Subnautica. You can find which version was used to build Subnautica in the log file in the Subnautica root directory. For Legacy, that's the QModManager log, and for Stable it's the BepInEx log. In the top few lines, you should find a line that looks like this:

QModManager Log (Legacy)

Initialize engine version: 2019.2.17f1 (441)

BepInEx Log (Stable)

[Info   :   BepInEx] Running under Unity v2019.4.36.870

Assign your Prefab to an AssetBundle

When you select your prefab in the Assets window, this pane will appear in the bottom left:

If you don't have a prefab, then you need to go back a step and create one.

Next to the word "AssetBundle" there is a drop down menu. In there, you can create a new AssetBundle name and choose it for your prefab. See how I have an Asset Bundle named "atrama." Sometimes you have to click the drop down menu a few times for it to work. It's bad and that's not my fault.

Add the BuildAssetBundles Script

First you must create a directory called exactly "Editor" in the "Assets" folder of your Unity project. The name "Editor" is critical because it is a special folder name in Unity:

Inside the "Editor" folder you must create a script like this one. In fact, I use this exact text every time.

using UnityEditor;
using System.IO;

public class CreateAssetBundles
{
    [MenuItem("Assets/Build AssetBundles")]
    static void BuildAllAssetBundles()
    {
        string assetBundleDirectory = "Assets/AssetBundles";
        if (!Directory.Exists(assetBundleDirectory))
        {
            Directory.CreateDirectory(assetBundleDirectory);
        }
        BuildPipeline.BuildAssetBundles(assetBundleDirectory,
                                        BuildAssetBundleOptions.None,
                                        BuildTarget.StandaloneWindows);
    }
}

This adds a button to the bottom of the Assets menu in the Unity editor. So you should have the folder structure "Assets/Editor/thisFile".

The button is called "Build AssetBundles," and it does exactly what it says.

Build the AssetBundle

Go to the Assets tab at the top of the Unity Editor, and find the "Build AssetBundles" button and press it.

This might take several minutes to execute, but when you're done you should have a file given the same name you gave the AssetBundle in the Inspector earlier. This file will be stored in the Assets/AssetBundles folder, and it will be easily recognizable both by its lack of an extension (no file type) and by its considerable size. Any non-AssetBundles in the folder will by tiny in comparison- on the order of 1 or 2 KB.

You must then include your asset bundle with your mod. That means you should move it into your mod folder.