JetBrains Rider 2018.1 Help

Features

You can start with watching this 3-minute video where Matt Ellis gives a short overview of JetBrains Rider features for Unity Development.

Unity Explorer

By default, when working with a Unity project in Rider, the Solution window works in the Solution Explorer mode showing you only the Scripts part of a bigger Unity project. To see all the assets that constitute this project, you can switch the Solution window to the Unity Explorer mode: you will see exactly the same project tree as in the Unity editor.

solution unity explorer mode

Control over Unity editor

To reduce the time you spend context switching between Rider and the Unity editor, some of the Unity editor's functionality is exposed directly in Rider on the Unity toolbar located in the top right corner.

unity toolbar

The toolbar allows:

  • Controlling play mode: The Play, Pause, and Step buttons correspond to the same buttons in the Unity editor and work in the exact same way.
  • Refreshing the asset database: The unity refresh icon Refresh button causes 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 is also really helpful when adding a new .asmdef assembly definition file: create the file in Rider, save, click Refresh and Unity will generate a new project file that Rider will silently reload. Note that there is also an automatic refresh, which happens whenever a file is saved.
  • Accessing Unity Editor log and plugin settings: The unity actions icon Unity-related Actions drop-down list offers a number of useful actions, such as opening Rider's Unity specific settings, and opening the log viewer.

Editor tips

  • JetBrains Rider marks classes, methods and fields that are implicitly used by Unity directly in the editor.
    unity editor icons
  • The UnityEngine.Color and UnityEngine.Color32 colors are highlighted, and hitting Alt+Enter will open the colour palette editor to modify the color. Also named colours and Color.HSVToRGB are supported.
    unity colors

Event functions

  • You can generate event functions using Unity Event Functions the Generate Code menu (Alt+Insert). This action is also available from Alt+Enter on a Unity-based class' name.
    unity generate event functions
  • Auto-completion will suggest event function names when declaring methods in Unity-based classes, and expand to include method signature. Simply start typing an event function within a class deriving from a known Unity class, such as MonoBehaviour.
    unity events autocomplete
  • Descriptions for event functions and parameters in Unity based classes are shown in tooltips and Quick Documentation.
    unity quickdoc

Inspections and quick-fixes

  • When the Solution-Wide Analysis is enabled, JetBrains Rider understands implicitly used fields and event functions and do not highlight them as not accessed.
  • Empty event functions are shown as dead code, with a quick-fix to remove them.
  • Using the SyncVarAttribute inside any class other than NetworkBehaviour is treated as an error.
  • A quick-fix is suggested to create a serialized field from a usage of an unresolved symbol:
    unity serialized field
  • JetBrains Rider ensures that all of your event functions have correct signatures: it highlights incorrect signatures and offers a quick-fix to correct them:
    unity signature
  • JetBrains Rider warns you against using an inefficient string literal comparison with the tag property, and provides a quick-fix to rewrite this as a call to CompareTag.
    unity comparetag
  • JetBrains Rider warns you if you try to use the new keyword to create a new instance of a class deriving from MonoBehaviour or ScriptableObject. A quick-fix is suggested to use gameObject.AddComponent<T>() or ScriptableObject.CreateInstance<T>() instead.
  • There are also inspections for the [InitializeOnLoad] and [InitializeOnLoadMethod] attributes, ensuring that they have the correct method or constructor signatures, and JetBrains Rider will grey out a redundant [InitializeOnLoad] attribute if the class doesn't have a static constructor, with a quick-fix to either quickly remove the attribute, or create the constructor.

External annotations

A lot of Unity-specific assemblies are annotated with External Annotations to improve code inspection when you make use of these assemblies.

  • Treating code marked with attributes from UnityEngine.dll, UnityEngine.Networking.dll and UnityEditor.dll as implicitly used.
  • Marking Component.gameObject and Object.name as not-nullable.
  • Debug.Assert marked as assertion method to help null-value analysis (e.g. "value cannot be null" after Debug.Assert(x != null)).
  • Debug.AssertFormat, LogFormat, etc. gets string formatting helper functionality.
  • Assertions.Assert methods marked as assertion methods to help null-value analysis.
  • EditorTestsWithLogParser.ExpectLogLineRegex gets regular expression helper functionality.
  • Various attributes now require the class they are applied to derive from a specific base type. E.g. [CustomEditor] requires a base class of Editor.
  • Support for Unity 2017.2's modularised UnityEngine assemblies.

Support for .shader files

JetBrains Rider provides the initial support for ShaderLab syntax in .shader files, with limited support for Cg/HLSL blocks.

  • Syntax and syntax error highlighting for ShaderLab syntax.
  • Color Assistance:
    unity shader colors
  • JetBrains Rider provides simple completion based on words found in the current file.
    unity shader completion
  • Brace matching and highlighting, comment/uncomment (Ctrl+Alt+/), and to-do explorer support.
    unity shader todo
  • Code folding.
    unity shader folding
  • [Cg/HLSL] Syntax highlighting for CGPROGRAM/ CGINCLUDE blocks and .cginc files.
  • [Cg/HLSL] Simple word based completion in Cg/HLSL blocks.
    unity shader hlsl completion

Live templates

  • JetBrains Rider offers a number of file templates for new C# script, tests, and shader files:
    unity filetemplates

Unity logs

unity log window

When Rider is connected to the Unity editor, the Unity tool window becomes available. To open the window, select View | Tool Windows | Unity on the main menu or use the Unity-related Actions drop-down list on the Unity toolbar.

The Log tab of the Unity tool window brings Unity's Console into Rider. The tab shows Unity log entries and is updated as events are logged in Unity.

The Output part of the window on the right shows the content of the currently selected log entry. Rider makes the content interactive, so that you can navigate to any source file, class, method or property mentioned in the log entry.

Note that log entries can be filtered by event type: events from play or edit mode, warnings, errors, and messages.

Last modified: 21 June 2018