Skip to content

Commit

Permalink
fix #2361
Browse files Browse the repository at this point in the history
  • Loading branch information
van800 authored and Merge Robot committed Oct 11, 2022
1 parent d91a752 commit ef81a64
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
15 changes: 13 additions & 2 deletions unity/EditorPlugin/EditorPrefsWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ public static string ExternalScriptEditor

public static bool AutoRefresh
{
get => EditorPrefs.GetBool("kAutoRefresh");
set => EditorPrefs.SetBool("kAutoRefresh", value);
get
{
var legacyAutoRefreshMode = EditorPrefs.GetBool("kAutoRefresh") ? AssetPipelineAutoRefreshMode.Enabled : AssetPipelineAutoRefreshMode.Disabled;
return EditorPrefs.GetInt("kAutoRefreshMode", (int)legacyAutoRefreshMode) >= 1;
}
}

// copy from UnityEditor.AssetPipelineAutoRefreshMode
private enum AssetPipelineAutoRefreshMode
{
Disabled = 0,
Enabled = 1,
EnabledOutsidePlaymode = 2
}

// This is an internal Unity setting. Introduced in 2018.2 (moved in 2018.3). The enum is internal, so we can only
Expand Down
17 changes: 15 additions & 2 deletions unity/EditorPlugin/PluginEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,21 @@ void SendResult()
}
else
{
refreshTask.Set(Unit.Instance);
ourLogger.Verbose("AutoRefresh is disabled via Unity settings.");
if (EditorApplication.isPlaying)
{
refreshTask.Set(Unit.Instance);
ourLogger.Verbose("Avoid calling Refresh, when EditorApplication.isPlaying.");
}
else if (!EditorPrefsWrapper.AutoRefresh)
{
refreshTask.Set(Unit.Instance);
ourLogger.Verbose("AutoRefresh is disabled by Unity preferences.");
}
else
{
refreshTask.Set(Unit.Instance);
ourLogger.Verbose("Avoid calling Refresh, for the unknown reason.");
}
}
});
return refreshTask;
Expand Down

0 comments on commit ef81a64

Please # to comment.