Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset bundles guide #534

Merged
merged 11 commits into from
Mar 1, 2024
Prev Previous commit
Next Next commit
Grammar changes and formatting
  • Loading branch information
Indigocoder1 committed Feb 28, 2024
commit 2d9cd125557f855215093596263b8841b1938fc7
33 changes: 18 additions & 15 deletions Nautilus/Documentation/guides/assetbundles.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Here are some things you will need to know:
- Basic modding and C# knowledge
- Basic knowledge of how to navigate the Unity game engine interface

The first thing you will need to do (Assuming you have a model already) is download the Unity Hub.
The first thing you will need to do (Assuming you have a model already) is download the Unity Hub.
This is where you will get the Unity version you need to use to export your asset bundle.

The version Subnautica uses is 2019.4.36 for SN1, as well as Below Zero.
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -17,36 +17,37 @@ Here are the download links you will need:
- Unity hub: [https://unity.com/download](https://unity.com/download)
- Unity version archive: [https://unity.com/releases/editor/archive](https://unity.com/releases/editor/archive)

LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
Once you've installed both, open Unity hub and click "New Project" from the top right.
Once you've installed both, open Unity hub and click "New Project" from the top right.
Once there, select 3D Core, choose your project name and then click "Create Project".
![assetbundles-project-setup](../images/guides/assetbundles-project-setup.png)

If you get the error "Failed to resolve project template", follow these steps:
1. Locate where your editor is.
You can do that by opening Unity Hub, going to Installs then right clicking on the version in question and clicking on "Show in Explorer"
2. Go to ``Editor\Data\Resources\PackageManager\ProjectTemplates``. You will find a ``manifest.json`` and ``UnityLicense.json`` files, delete them both.
3. Kill Unity Hub in your task manager and open it again.

You should now be able to create your project!
> [!NOTE]
> If you get the error "<font color="red">Failed to resolve project template</font>", follow these steps:
> 1. Locate where your editor is.
> You can do that by opening Unity Hub, going to Installs, and then right clicking on the version in question and clicking "Show in Explorer"
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
> 2. Go to ``Editor\Data\Resources\PackageManager\ProjectTemplates``. You will find a ``manifest.json`` and ``UnityLicense.json`` files. delete them both.
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
> 3. Kill Unity Hub in your task manager and open it again.
>
> You should now be able to create your project!

The Unity editor will now open. This may take a while.
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
Once the editor is open, drag your model from your file manager into the Scene window
Once the editor is open, drag your model from your file manager into the Scene window.

You can either click on your model in the scene window or in the hierarchy on the left to select it and use transformations on it
You can either click on your model in the scene window or in the hierarchy on the left to select it.

Next, click on ``Window`` at the top of the Unity editor, and then click ``Package Manager``.
Click on the dropdown at the top left and select ``Unity Registry`` if not on it already.
Search for "Asset Bundle Browser" and install it.

LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
Next, drag your model from the hierarchy on the left into the ``Assets`` section at the bottom.
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
This will create what is called a Prefab. It can be instantiated (created/spawned) multiple times but they are all copies of the original.
This will create what is called a ``Prefab``. It can be instantiated (created/spawned) multiple times, but they are all copies of the original.

To edit the prefab, double click on it in the ``Assets`` window.
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
You can add components to the prefab by clicking "Add Component" in the inspector on the right.
One example of a component is a ``RigidBody``, which can apply physics to your Prefab.
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
Any components you add will be included in the AssetBundle.

You **should not**, however, add scripts you made in the editor, as the AssetBundle will not link them to the scripts in your modding project and you will get errors.
You <font color="red">**should not**</font>, however, add scripts you made in the editor, as the AssetBundle will not link them to the scripts in your modding project and you will get errors.
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved

After all your prefab configuration is done, click on it in the ``Assets`` window, and click on "Asset Bundle" in the bottom right of the Inspector.
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
Here you can either assign your prefab to an existing AssetBundle or create a new one.
Expand All @@ -58,7 +59,7 @@ Here you can see all the assets that will be put into your AssetBundle.

Click on the build tab, and change the ``Build Target`` to "Standalone Windows" if it isn't already.
You can also configure the ``Output Path`` of the build.
Once all that is set, click ``Build``.
After all that is set, click ``Build``.

Once your AssetBundle is built, move the built file to the location of your mod in the Plugins folder.
I prefer to put them inside a folder namded "Assets", but that isn't necessary.
LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -108,4 +109,6 @@ To use this in a Nautilus prefab, just use
```csharp
myCustomPrefab.SetGameObject(myAssetBundleGO);
```
Instead of using a CloneTemplate.
Instead of using a CloneTemplate.

LeeTwentyThree marked this conversation as resolved.
Show resolved Hide resolved
This reaches the end of this guide. If you have more questions about AssetBundles, feel free to ask in the modding channels of the modding Discord.
Loading