Table of Contents

Development Setup Guide

This article covers a step-by-step guide of setting up your pc for Subnautica mod development. Please note that this setup works on any operating system, so if you're using a non-windows machine, don't worry! You're in the right place!

Note

Although we try to keep this guide as comprehensible as possible, we will not cover a C# tutorial. So a basic understanding of the language is still required. .NET Academy covers the basics in a simple interactable tutorial. If you need a more in-depth C# tutorial, the Giraffe Academy video is a good start.

To start developing, you will need to install some tools first:

  1. Latest .NET SDK
  2. An integrated development environment (IDE)
  3. BepInEx 5.4.21
  4. Nautilus

.NET SDK

.NET software development kit (SDK) is the main component of starting to write C# code. The SDK will take care of compiling our code, as well as enable the latest C# version features.
In Nautilus we always make sure to update to the latest C# versions. To enable numerous inspection warnings and convenience while working with Nautilus, we recommend you to update the .NET SDK to the latest version.

Tip

Microsoft usually schedules their .NET Core releases around November every year.

To install .NET SDK:

  1. Head to the .NET download page
  2. Select the latest recommended .NET SDK
    dotnet-sdk
  3. Download and run the installer. A restart may be needed to take place afterward.

To ensure that the SDK has installed correctly, open a terminal and run the following line:

dotnet --version

Output:

7.0.102

Picking an IDE

The top 3 IDEs for writing C# code are the following:

  • Visual Studio Community - Free, great IDE designed for .NET development (Windows and Mac only)
  • JetBrains Rider - Paid, outstanding IDE, incredible code-completion and code suggestions with the power of ReSharper, cross-platform
  • Visual Studio Code - Free, multi-purpose editor, cross-platform, can be used for C# development with plugins.

Installing IDE

  1. Download the installer from the Visual Studio download page and run it
  2. Inside the Visual Studio installer, ensure the .NET Desktop Development component is selected, then proceed with the installation.
    vs-install

Installing BepInEx

BepInEx is a mod loader that we use to load Subnautica mods to the game. We recommend using the Subnautica BepInEx Pack as it's configured specifically for the game. The installation process is explained in the provided link.

Installing Nautilus

  1. Download Nautilus from one of Nexus Mods, Submodica or GitHub Releases.
  2. Drop and drop the plugins folder in the zip file to: PathToSubnautica\BepInEx\

Installing Subnautica Modding templates

Since the project setup can be quite tedious for experienced developers and confusing for new-comers, we have published a series of templates to help you setup your projects more easily.

To install the template, run the following command in a terminal:

dotnet new -i Subnautica.Templates
Note

If you receive an error about not having any defined/enabled NuGet sources, you may need to run the following command first: dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org

Once the install is completed, you will receive an output similar to the message below displaying the process as successful.

Template Name                             Short Name      Language  Tags
----------------------------------------  --------------  --------  ---------------------------------------------
Subnautica Empty Template                 snmod_empty     [C#]      SNModding/Subnautica/Mod
Subnautica Nautilus Template              snmod_nautilus  [C#]      SNModding/Subnautica/Mod/Nautilus
Subnautica Template                       snmod           [C#]      SNModding/Subnautica/Mod
Subnautica: Below Zero Empty Template     bzmod_empty     [C#]      SNModding/Subnautica: Below Zero/Mod
Subnautica: Below Zero Nautilus Template  bzmod_nautilus  [C#]      SNModding/Subnautica: Below Zero/Mod/Nautilus
Subnautica: Below Zero Template           bzmod           [C#]      SNModding/Subnautica: Below Zero/Mod

Below is a description of what each of these templates represent:

Template Name Short Name (ID) Description
Subnautica Template snmod Contains all the essential configurations, dependencies, and a basic Plugin.cs with the Logger and harmony patcher.
Subnautica Empty Template snmod_empty Contains all the essential configurations and dependencies with no additional files.
Subnautica Nautilus Template snmod_nautilus Contains all the essential configurations, dependencies with Nautilus installed and a simple example demonstrating the usage of Nautilus.

The Subnautica: Below Zero templates contain the exact same configurations as their corresponding Subnautica versions, except they install BZ dependencies instead.

Creating a new mod project

Once you installed the templates, they will appear among other templates in the "Create new project" section of your favorite IDE. vs-template-default

You can also create the project using CLI:

dotnet new snmod -n MyBeautifulMod

Now you can add more code to the project, then build and put the compiled dll in Subnautica/BepInEx/plugins/.

Note

If you are using an empty template, please ensure that in your entry point class (the class that has a [BepInPlugin] attribute, usually called Plugin.cs) Nautilus is marked as a dependency if you use it. To add the dependency, simply add the [BepInDependency("com.snmodding.nautilus")] attribute at the top of your entry point class. You may find an example here. For more information, visit the BepInEx docs.