Skip to content

Attaching a debugger

This guide is an adaptation of this post by CuteLasty

Prerequirements

Extract development files from Unity installation

  1. First, you need to determine what version of Unity used to build the game. To do so, see properties of UnityPlayer.dll file from the game folder. Under Details tab, there's Product version property. For example, if this property contains something like 2020.2.2.1234 we need 2020.2.2 version of Unity.
  2. Download and install correct version (2020.2.2 in our case) of Unity. Don't choose any additional components other than Unity itself. It can be uninstalled after finishing this guide, so don't care much where you install it, but remember the folder.
  3. After installation complete, navigate to the folder where you just installed Unity, then to the Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win64_development_mono\ subfolder, and do the following:

    File Action
    UnityPlayer.dll Replace the one in the game folder
    WinPixEventRuntime.dll Replace the one in the game folder
    WindowsPlayer.exe Replace VoxelTycoon.exe in the game folder

Important

If the Unity version used to build the game will change, you'll need to repeat this guide using correct version.

Put the game itself into development mode

Open VoxelTycoon_Data\boot.config and add these strings:

wait-for-managed-debugger=1
player-connection-debug=1

Attach a debugger

  1. Rebuild your mod, and place .dll and .pdb files to your mod folder inside the game's Content\ folder.
  2. Now run the game and you should see a dialog saying You can attach a managed debugger now if you want.
  3. In Visual Studio, go to DebugAttach Unity Debugger, then double-click an item in the dialog shown.

That's it! Now you able to set break points on your mod code, and inspect variable values.

Important

The game running in the development mode will have reduced performance, so after you end with debugging your mod, you'll want to restore game files to the original state. To do so, just verify integrity of game files.

In this case (or with each game update) all the changes you made following this guide we'll be lost. To avoid this you can copy UnityPlayer.dll, WinPixEventRuntime.dll, VoxelTycoon.exe, and VoxelTycoon_Data\boot.config files into some backup folder, so you can copy it back later without need to install Unity again.

Troubleshooting

  • Ensure that Project propertiesBuildAdvanced…Debugging information is set to Portable.
  • Ensure you have Visual Studio Tools for Unity installed.

Last update: July 26, 2023