Monthly Archives: May 2018

Debugging a Godot C# Project using Jetbrains RIder

Currently you know how to debug godot using vs code, but my personal favorite IDE is Jetbrains Rider because I know most of the hotkeys and I use their other IDE’s for work on a daily basis. Rider just made sense, plus nothing beats an IDE made for working with a language.

(We’ll be using this project for this example)

Setting up your godot project

So lets get right to it. The first process is similar to the vs code tutorial, we need to double check a few settings in your godot project. So first go to Project -> Project Settings -> Mono -> Debugger Agent and make sure “Wait For Debugger” is checked. Next we want to change the wait time, the time is set using milliseconds, I personally increased this value to 10 seconds because it gives you a little time to enable the debugger and let it set itself up before attaching itself to your godot project.

setup godot csharp jetbrains rider

Setting Remote Debugging in Jetbrains Rider

In order for jetbrains to connect to the mono debugger we need to setup our configuration. So first select the drop down below Tests and Tools menu and hit Edit Configuration. Next we want to add the new configuration by pressing the green plus symbol and selecting Mono Remote. From here we rename our remote debugger, I used “Godot” as the name, set our host and we want to share the remote debugger so check that option as well. We’ll leave the port default for now. Hit Apply then hit Okay.

jetbrains configuration godot 3 csharp remote debugging

Now we need to setup the port for Rider to match the debugger in Godot

First go back to your debugger settings in your godot project and copy the debugger port

copy port godot jetbrains remote debugger

Next we need to edit our configuration in jetbrains. So like we did before use the drop down and select edit configuration, find our remote mono configuration and paste the port we used in our godot project.

Lets Debug!

Now to debug it’s simple, I start by running the godot application either by individual scenes or the full game by pressing the play button either works. Wait for the window to popup then head over to jetbrains rider and hit the debug icon and wait a second. If successful you’ll see variables in the debugger and you should be able to do everything you could with the debugger such as step in, step out, etc… I will note that sometimes the debugger may not work, simply just repeat these steps and wait a second after the window launches before trying to debug and it should work normally.

jetbrains rider debug test godot csharp

Wait, I still can’t get debugging working in my current application!

There’s a chance that you have some unhandled exceptions in your application and the debugger by default does not catch them. Take a look here where I purposely add a NullReferenceException to my application.

exception jetbrains rider csharp

So how do you fix this you ask? It’s very simple. First click on the Run menu and go to the very bottom and select View Breakpoints or CTRL+Shift+F8 (on windows). Next check Any Exception under .NET Exception Breakpoints and try debugging again. (note: you can manually add specific exceptions if you highlight .NET Exception Breakpoints then hitting the Plus sign and typing in an exception name)

exception jetbrains rider csharp

And that’s about it. Happy Debugging!

Catching Exceptions when debugging your c# godot projects using visual studio code & Mono Debug Extension

So the guys over at Godosharp.Net wrote an article on how to setup the mono-debug extension to work with your godot projects. Well currently out of the box exceptions are not caught by default and you may want to catch NullReferenceException‘s when working on your games. So after combing through some source on the plugin I figured out how to do just that.

First you need to open your user settings.

As long as you have the Mono Debug extension installed start typing mono-debug and it should auto complete. If the auto complete doesn’t work you can simply add the following setting block to your user settings file and restart the editor.

Now to test add something like public Random Rand; to your scene script and try to debug. Currently we only have NullRefenceException enabled, but you can choose between never, always and unhandled. In the above settings to catch exceptions.

Happy Debugging!

Getting Visual Studio Code & Godot 3.0 Mono working on Windows

When working with godot 3.0 and the C# api you may want to have some intellisense support. Well, lately there’s been some confusion on how to properly get that working and I’m going to help you get started in a few easy steps.

Requirements

Download & install the following

Now Omnisharp requires Windows 8 (.NET 4.5) SDK or the intellisense will not work.  Some people may already have this installed, some may not, but if intellisense doesn’t work this is one of the root causes on why it’s not working.

Gotcha: If your project name has spaces then omnisharp may not pick up the project and you’ll need to remove the spaces from your project name and files. Rule of thumb: never have spaces in your project name or filenames, it’ll probably cause more problems than it should.)

Get Coding

Once you’ve built your project, by either pressing the start scene icon or manually building from the mono tab at the bottom of your editor, open the project folder inside visual studio code. Now you should test the intellisense by typing GD.P to see if GD.Print auto-completes. If it auto-completes the godot method then you’ve successfully setup visual studio code to work on your godot 3 C# projects!

Happy Deving