ruk·si

Unity
Rider IDE

Updated at 2017-08-28 10:49

MonoDevelop, the default Unity C# IDE, is crap. Some people like to use Visual Studio but I'm a heavy JetBrains user so I prefer their C# IDE called Rider.

How to setup Rider for Unity:

  1. Download JetBrains Rider.
  2. Install Rider; the installer will suggest "Unity" plugin, make sure you install it.
  3. Download and install Unity.
  4. Open Unity and open a project.
  5. Edit > Preferences > External Tools, select Rider e.g. "C:\Program Files\JetBrains\Rider 2017.1 RC\bin\rider64.exe" or "/Applications/Rider.app".

On Windows: rest of the setup is easy:

  1. When you first open Rider through Unity, it will install the Rider plugin into your Unity project.

On Mac: you need to install it ourself.

  1. Copy these files into a Assets/Plugins/Editor/JetBrains directory.
  2. Open a code file within Unity UI to startup Rider.
  3. Configure mono binary at Rider > Settings > Build... > Toolset.. > Mono executable, set it to "/Volumes/Extraspace/Applications/Unity 5.6.2/Unity.app/Contents/MonoBleedingEdge/bin/mono" or a variation of that.

Disable auto-save in Rider. Rider will suggest this but auto-saving will cause Unity Editor to recompile every time you switch back to Unity. Disable it from tooltip or through Rider > Settings > Appearance &... > System Settings > Save files on frame deactivation.

Edit Rider settings to your liking. These are my basic settings.

  • Turn off "Namespace does not correspond to file location" inspection.
  • Turn off all code folding.
  • Turn on "Ensure line feed at file end on save".
  • Turn on "Code Style > C# > Other > Line feed at end of file".
  • Turn on "Show whitespaces".
  • Change font to "Menlo", or "Consolas", size 12.
  • Set right margin to 80.
  • Install "GoToTabs" IDE plugin through Settings and bind keys to it.
  • Now IDE will format your code whenever you press Ctrl + Alt + L.

If you want to debug something, add break points to code in Rider and press the bug icon top right of the IDE. This works even if Unity player is running and stopping debugging won't crash Unity.

Setup edit mode tests. Edit mode tests are unit tests that you can run without starting the game. Unity > Window > Test Runner > Create EditMode test and now you have a folder with a test file NewEditModeTest.cs. You can run tests with the Run All button in Unity > Test Runner.

using UnityEngine.TestTools;
using NUnit.Framework;
using System.Collections;

public class NewEditModeTest
{
    [Test]
    public void NewEditModeTestSimplePasses()
    {
        Assert.AreEqual(true, true);
    }

    // A UnityTest allows you to yield null to skip a frame in EditMode.
    [UnityTest]
    public IEnumerator NewEditModeTestWithEnumeratorPasses()
    {
        yield return null;
        Assert.AreEqual(true, true);
    }
}

Theoretically you could run some of the tests inside Rider, but it has been too much hassle for me personally.

For more hardcore tests, use play mode tests. Play mode tests look the same but are run inside Unity Editor play mode or standalone window with the real game context. But they will increase your binary size, to disable play mode tests right click on the "Test Runner" tab and click "Disable play mode tests".