Skip to content

Commit f52edb8

Browse files
committed
Added debugger guide.
1 parent 4f7421f commit f52edb8

File tree

8 files changed

+86
-1
lines changed

8 files changed

+86
-1
lines changed

ModdingGuide/ModdablePrefab.MD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: "Make a code-less mod (using JSON) with Moddable prefab"
3+
description: A comprehensive guide to making mods for Timberborn
4+
date: 2025-03-13
5+
tags: mods timberborn guide modding
6+
---
7+
8+
Placeholder content

ModdingGuide/attach-debugger.MD

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: "Attach a Debugger to Timberborn"
3+
description: A comprehensive guide to making mods for Timberborn
4+
date: 2025-03-13
5+
tags: mods timberborn guide modding debugging
6+
---
7+
8+
[Home](../) / [Modding Guide](./) / Attach a Debugger to Timberborn
9+
10+
**This guide can be done totally thanks to `normanr`. All credits go to him. I just made a few changes to make it easier to follow. Parts of this guide is from [dnSpy's guide](https://github.com/dnSpy/dnSpy/wiki/Debugging-Unity-Games#turning-a-release-build-into-a-debug-build) and [Let's Play with Fire Wiki](https://wiki.fireundubh.com/unity/turning-a-release-build-into-a-debug-build).**
11+
12+
This short guide will show you how to attach a debugger to Timberborn and debug the game code or your mods using DnSpy and Visual Studio.
13+
14+
- With dnSpy, you can debug the game code using the game's assemblies (DLLs) or ripped assemblies from AssetRipper.
15+
- With Visual Studio, you can debug your mod code.
16+
17+
# Installation guide
18+
19+
1. Determine and install the Unity version the game is using:
20+
- Right click on the Timberborn executable and select `Properties`. Go to the `Details` tab and look for `Product version`. For example at the time of writing, the version is `6000.0.36f1`.
21+
![Timberborn executable properties](./img/unity-version.jpg)
22+
- Go to [Unity Download Archive]( https://unity.com/releases/editor/archive) and download the corresponding version (you don't actually need to run it, just need some files from it).
23+
24+
> **Tip:** while waiting for the download and installation, you should make a backup of your game's folder.
25+
I myself even create Git repository for the game folder, then create a branch called `dev-build` so I can easily switch between the dev build and the normal game because the Dev build does have a lot of dev UI that are not useful when you are not debugging the game.
26+
27+
2. Go to this folder you just installed, `Unity 6000.0.36f1\Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win64_player_development_mono`:
28+
- Copy the content of the `Data` folder over to your game's `Timberborn_Data` folder, overwriting everything.
29+
- Copy `WindowsPlayer.exe` + `UnityPlayer.dll` to your game's folder (where `Timberborn.exe` is). Rename or delete the original `Timberborn.exe` then rename `WindowsPlayer.exe` to `Timberborn.exe`.
30+
31+
3. Edit `Timberborn_Data\boot.config` and add these two lines:
32+
33+
```ini
34+
wait-for-managed-debugger=1
35+
player-connection-debug=1
36+
```
37+
38+
4. (Optional) If you want to use Visual Studio, make sure you have "Game development with Unity" installed. You can check this in Visual Studio Installer.
39+
40+
![Visual Studio Installer](./img/vs-unity-tools.jpg)
41+
42+
That's it. If you use my tip above, now you can make a commit into the new branch `dev-build` and you can switch between the dev build and the normal game easily.
43+
44+
# Debugging with DnSpy
45+
46+
You can either use `Start` command or `Attach to Unity` command in DnSpy. Then you simply load the game's DLLs (either directly from the game folder or from AssetRipper) and you can put breakpoints and debug the game code.
47+
48+
![DnSpy Start](./img/dnspy-start.jpg)
49+
50+
For example, I put a breakpoint at `Timberborn.BlockSystem.BlockObjectFactory.CreateUnfinished` for when I want to know what happens when I build a building:
51+
52+
![DnSpy Breakpoint](./img/dnspy-debug.jpg)
53+
54+
# Debugging with Visual Studio
55+
56+
> **Note:** in order to debug your mod's code, make sure you built your mod with embedded Debug symbols. You need this in your `csproj` file:
57+
58+
```xml
59+
<PropertyGroup>
60+
<!-- Others code -->
61+
<DebugSymbols>true</DebugSymbols>
62+
<DebugType>embedded</DebugType>
63+
</PropertyGroup>
64+
```
65+
66+
Then when the game run, you can click `Debug > Attach Unity Debugger` in Visual Studio and select the `Timberborn.exe` process. You can put breakpoints in your mod's code and debug it like a normal C# project.
67+
68+
![Visual Studio Attach Debugger](./img/vs-debugging.jpg)
69+
70+
---
71+
72+
[Back to Modding Guide](./)

ModdingGuide/img/dnspy-debug.jpg

431 KB
Loading

ModdingGuide/img/dnspy-start.jpg

49 KB
Loading

ModdingGuide/img/unity-version.jpg

43.6 KB
Loading

ModdingGuide/img/vs-debugging.jpg

193 KB
Loading
148 KB
Loading

ModdingGuide/index.MD

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ Useful external links:
3030
4. _(Optional)_ [Useful knowledge of Timberborn architecture](./timberborn-architecture): My experience and knowledge about Timberborn's codebase that may come in handy when making mods.
3131
5. _(Optional)_ [Advanced Modding Techniques](./advanced-modding): Some techniques I use in my mods to make modding easier and less repetitive.
3232

33+
Extra useful stuff:
34+
35+
- [Attach a debugger to Timberborn](./attach-debugger): How to attach a debugger to Timberborn and debug the game code or your mods using DnSpy and Visual Studio.
36+
3337
The following sections are more specific to certain types of mods that I made:
3438

3539
1. [UI modding with TimberUi](./timber-ui): How to make UI mods for Timberborn using [TimberUi](../TimberUI).
3640
2. [Make a mod with Buff & Debuff mod](../BuffDebuff): Adding customizable buffs and debuffs to various in-game entities.
37-
3. [Make a mod with Scientific Projects mod](../ScientificProjects): Adding new research projects to the game.
41+
3. [Make a mod with Scientific Projects mod](../ScientificProjects): Adding new research projects to the game.
42+
4. [Make a code-less mod (using JSON) with Moddable prefab](../ModdablePrefab): Adding components to a prefab or changing their values using JSON (Blueprints) files.

0 commit comments

Comments
 (0)