Refresh Unity Assets
By default, Unity is set to automatically refresh assets (you can change this in the Unity Editor with
). If you use Unity in conjunction with Rider, the auto-refresh is triggered in two cases:when you focus the Unity Editor window,
by Rider, for example, when you save your project, run unit tests, or perform some other actions (see below).
Trigger refresh in Unity editor
Time after time you need to trigger refresh in 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). By default, JetBrains Rider triggers the assets refresh in Unity when you make significant changes to the project:
You save a file or all files in the project (excluding autosave).
You add a new
.cs
file to the project.You run unit tests.
You perform VCS pull.
If you want to disable this behavior, clear the Automatically refresh assets in Unity checkbox on the page of JetBrains Rider settings Ctrl+Alt+S.
Although automatic refresh covers most of the cases, JetBrains Rider also allows you to manually trigger refresh in Unity editor, which may be especially useful if you want to run or debug the startup code in Unity.
Configure manual triggering of refresh in Unity editor
Right-click one of the buttons on the Unity toolbar and choose Customize Toolbar....
In the dialog that opens, click Add Action....
In the dialog that opens, find and select the Refresh Unity Assets action, click OK, and then apply changes in the Customize Toolbar dialog.
Now you can click the Refresh Unity Assets button on the toolbar each time you want to trigger refresh in the Unity editor.
Refreshing assets in the play mode
Auto-refreshing assets is usually a great way to work, but it may be inconvenient in the play mode as the recompile may reset game data. Note that Rider does not refresh assets if Unity is in the play mode. Therefore, this may be the problem only when you focus the Unity Editor window after running the play mode from Rider. To solve this issue, in Unity Editor, in *, specify how the auto-refresh should be done in the play mode:
Recompile and Continue Playing: may reset game data.
Recompile after Finished Playing: Recommended if you do not want the changes to affect the play mode.
Stop Playing and Recompile: stops the play mode and may reset game data.