Control Unity editor play mode with Rider 2018.1

One of our big themes with Rider’s Unity support is to reduce how much time you spend context switching between Rider and the Unity editor, and Rider 2018.1 introduces some new features that are designed to do just that.

Our new secret sauce is that we’ve improved our existing Unity editor integration. We’ve added a much smarter editor plugin that opens up two way communication between Rider and the editor. This means the editor can talk to Rider, to tell it to open a C# file that’s just been double clicked, but even better, it means Rider can now talk to the editor, and tell it to do things, such as switch to play mode.

In this series:

Over the next couple of posts, we’re going to take a look at some of the ways this will help reduce context switching, namely a log viewer to bring Unity’s console log directly into Rider, and integration with the unit test runner.

But for this post, we’ll start nice and easy, with a look at how to get installed and up and running, and the new controls that deal with play mode.

Getting started

The good news is that Rider will handle installing and upgrading the editor plugin for you. There are a couple of things you should be aware of, but nothing too scary – remember that the Unity editor plugin is per project, and installed into your Assets folder.

This version of Rider replaces the existing  Unity3DRider.cs script based editor plugin with an assembly – JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll. Rider will automatically find and delete the old C# file, even if it’s been moved, and automatically copy the assembly to Assets/Plugins/Editor/JetBrains/.

Plugin installed notification

If you had previously committed Unity3DRider.cs into source control, now’s the time to delete it. We also strongly recommend excluding the new .dll from source control, for several reasons. Firstly, it’s a binary file, and will only cause your repository to grow. Secondly, Rider will automatically keep the assembly up to date, copying a new version across whenever you run a new version of Rider (this behaviour can be changed in settings). And thirdly, we actually install a different version of the plugin for versions of Unity 5.5 and below. We suggest updating your  .gitignore file or equivalent to exclude  JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll.

Talking to the editor

Enough with the boring install details. On to the fun stuff!

Once a project has been loaded with the new plugin (you might need to switch focus back to the editor if you’ve just installed it), Rider and the Unity editor should now be connected. This is shown with a small Unity icon in the status bar, marked with a green dot to indicate a live connection.

Status bar icon showing Rider connected to Unity

Or a plain icon if Rider can’t make the connection.

Status bar icon showing Rider not connected to Unity

You might also notice some other changes to the UI. We’ve started to streamline the UI when you open a Unity project. Firstly, we’re hiding some tool windows that are less relevant while working with Unity, such as the NuGet and Database tool windows. Also, we’re hiding the Debug/Release configuration selector, and introducing a new, Unity specific mini toolbar in the top right of the IDE.

New Unity toolbar

Controlling play mode

One of the main benefits of the new plugin architecture is that we can now expose Unity editor functionality directly in Rider, such as switching to play mode. The new toolbar includes play/pause/step buttons that correspond to the same buttons in the Unity editor, and control the behaviour just as you’d expect. You can now switch into and out of play mode, pause and step a single frame, all from Rider.

We haven’t yet added keyboard shortcuts for these actions (finding consistently available shortcuts across the 14 different keymap schemes that ship with Rider is surprisingly tricky!) but you can add your own if you search for “Unity” in the Keymap settings page.

The Refresh icon on the toolbar will cause the Unity editor to refresh the asset database, which will cause the Unity editor to import any newly added assets, and if necessary, compile the project and regenerate the solution files (which Rider will silently reload). This is useful when adding new files through Rider, either by refactoring and renaming a file, or by adding new C# script or shader via file templates. It’s also really helpful when adding a new .asmdef assembly definition file – create the file in Rider, save, hit refresh and Unity will generate a new project file that Rider will silently reload, all without leaving Rider, or being blocked from working. And we also have an automatic refresh, which happens whenever a file is saved.

Finally, there’s the Unity related action drop down. This menu offers a number of useful actions, such as opening Rider’s Unity specific settings, and also opening the log viewer, which we’ll take a look at in the next post.

Unity actions

Download Rider today, and give the new Unity editor integration a go! Let us know how you get on – leave comments here, or raise an issue in YouTrack or on GitHub.

This entry was posted in How-To's and tagged , . Bookmark the permalink.

5 Responses to Control Unity editor play mode with Rider 2018.1

  1. George cook says:

    I love you guys.

  2. Olivier Pons says:

    Maybe the “Show Unity Editor Log” option could be a button next to “Play”. I’m often opening/closing the log.

  3. Bernat Centellas says:

    Well done! But it would be great if Rider has the option to search into the Unity Editor Log (thing that Unity doesn’t support).

Leave a Reply

Your email address will not be published. Required fields are marked *