Using Jetbrains’ Rider IDE with Unity

In my daily work I use phpStorm intensively and as such I have become used to the convenience that the IntelliJ family of products give.

A little bit of background

Aside from my work as PHP Developer I also create interactive media solutions, such as games, using Unity. But with Unity the default editor is Mono Develop; and while Mono Develop does its job it is nowhere near the usability that IntelliJ IDE’s offer.

Then a few months ago Jetbrains introduced the EAP for Rider, their new C# IDE. I was overjoyed when it came out but alas, no Unity support until early August when Jetbrains adopted a community-written Unity Editor Script that resolves most of the issues that you encounter.

Setting up Unity to use Rider

For this blog post we used the latest version of the plugin at https://github.com/JetBrains/Unity3dRider/tree/b7c6637acfc547a635df293d87710b9c8dd9e45e. I am going to expect there to be new versions in the future so your mileage may vary with the instructions below.

The process is rather straightforward:

  1. Set Rider as your editor of choice in the External Tools section of Unity’s Preferences dialog
  2. Create a folder Assets\Plugins\Editor if it doesn’t exist yet
  3. Download this Unity Script to the above folder as RiderUnityIntegration.cs
  4. Navigate to the Assets menu item in Unity and select Open C# Project

The first time I followed this instructions I was greeted by the project selection dialog of Rider; once I opened the solution from that dialog once it just worked every subsequent time.

Debugging Unity Scripts

There is once caveat: by default Rider won’t start a debugging session when you initiate it from Unity. To be able to attach Rider to the C# Debugger you can follow the steps described here or read on. In short it comes down to looking up the port number to which the C# Debugger is emitting calls and manually connecting it.

At time of writing the most effective technique would be to determine the port number using the following bash command:

lsof -c /^Unity$/ -i 4tcp -a

Or, if you are on Windows, open the Editor log file and look for a line similar to “Using monoOptions –debugger-agent=transport=dt_socket,embedding=1,defer=y,address=0.0.0.0:56396”; the number “56396” is the port number that you are looking for.

Be aware that the port number changes every time you restart Unity. You will have to repeat these tricks everytime when you restart it.

Once you have done that you can create a new Mono Remote Debug Configuration in Rider, set it to use the host 127.0.0.1 and the port that you obtained above. Also don’t forget to check the Single Instance only checkbox.

After you have done that you can press the Debug button and there you go: Debugging works!

3 thoughts on “Using Jetbrains’ Rider IDE with Unity

  1. Rider private eap 12 has debug Unity outofthebox – call Run-> Attach to local processes.

  2. Hi there, followed your instruction but still can’t get Rider debugging working on Windows ?

    Just get “Input/Output redirection disabled: Debugger is attached to already running process” in the Console .

    Would be great to get this last piece of the puzzle working! 🙂

Comments are closed.