Refreshing 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).
Note that refreshing the assets may be time consuming as Unity recompiles the code on each refresh.
How Rider triggers Unity Editor auto-refresh
To save your time, Rider triggers the assets refresh in the background while you work. This is how the refresh is triggered:
You save a file or all files in the project.
You add a new
.csfile to the project.
You apply a refactoring action.
You run unit tests.
You perform VCS pull.
You explicitly call the Refresh Unity assets action, for example, by clicking the button on the toolbar. This may be especially useful if you want to run the startup code in Unity.
If you do not want Rider to refresh assets, clear the Automatically refresh assets in Unity checkbox in .
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.