Please be aware that this mod is in it's early stages of development, and that the steps below are to set up a development environment for Nitrox. These steps are not for a regular install of this mod. We discourage the use of this mod for casual play until a stable public release has been made.
- Fork the repository to your own Github account (use the fork button top-right).
- Pull git repository locally (pass
--recursive
togit clone
to init and clone submodules).- e.g.
git clone https://github.com/your-github-name/Nitrox.git --recursive
- e.g.
- Initialize git submodule(s) by running the following command:
git submodule update --init --recursive
. This command can also be used to fetch and update changes.
-
Load
Nitrox.sln
inside Visual Studio -
If you have Subnautica installed via Steam in the default install location, skip this step.
- Open
DevVars.targets.example
- Adjust the line
<SubnauticaDir>C:\Program Files\Epic Games\Subnautica</SubnauticaDir>
to match the location of your Subnautica install directory. - Save the file as
DevVars.targets
- NOTE: If you have this file, it will always use this directory and never use the default steam directory.
- Open
-
Build entire solution to generate binaries
-
Inject
NitroxPatcher
intoAssembly-CSharp
:- Load up dnSpy
- Inject before the first line of
GameInput.Awake()
- Add a reference to
NitroxPatcher
. This should be in the same directory asAssembly-CSharp
. If not, follow step 3 more carefully. - Inject startup code:
NitroxPatcher.Main.Execute()
. - If you get compile errors like in issue 221 you should be able to remove the offending lines without repercussions.
- Start Subnautica
- If you see a
multiplayer
button Nitrox is correctly loaded. - Verify Subnautica logs at
Subnautica/Subnautica_Data/output_log.txt
(Search fornitrox
, verify no errors)- NOTE: There will always be some errors, but nothing substantial in the first part regarding loading of Nitrox.
- Run NitroxServer project and verify that there are no errors in the console Window
- In the client, join a new game by connecting through the multiplayer button in the UI.
- Make sure you have the latest version of dnSpy installed.
- Swap Subnautica's release build
mono.dll
with dnSpy's patched version that can be debugged:- In the dnSpy releases, download the latest
Unity-debugging-5.x.zip
file. - After unzipping the file, navigate to
Unity-debugging/unity-5.6.2/win64
and pull out themono.dll
file. - Navigate to Subnautica's directory and swap out
Subnautica_Data/Mono/mono.dll
with themono.dll
you downloaded from GitHub.
- In the dnSpy releases, download the latest
- Start up Subnautica and dnSpy.
- While on the main menu, go to
Debug > Start Debugging
(or pressF5
) in dnSpy. - Select
Unity (Connect)
as the Debug engine, and press OK. - Once the bottom of dnSpy says "Running..." in orange, the debugger is now connected to Subnautica.
To view the game's code:
- Go to
Debug > Windows > Modules
, findAssembly-CSharp.dll
and double click it.- NOTE: You can also debug through Nitrox's code by finding Nitrox modules after the patcher loads them in.
You can place breakpoints anywhere in any of the modules and the game will pause and show all local variables when the breakpoint is hit.
NOTE: It might take a few seconds for the debugger to connect to your game. Be careful when setting breakpoints and pausing the game for long periods of time when it's in multiplayer, because you will be disconnected from the server after you resume execution due to timeout. It's recommended to attach the debugger before you join a multiplayer server.