@@ -2568,6 +2568,8 @@ public static void Schedule(string relPath, TimeSpan window)
25682568 // Kick off a ticking callback that waits until the window has elapsed
25692569 // from the last request before performing the refresh.
25702570 EditorApplication . delayCall += ( ) => Tick ( window ) ;
2571+ // Nudge the editor loop so ticks run even if the window is unfocused
2572+ EditorApplication . QueuePlayerLoopUpdate ( ) ;
25712573 }
25722574
25732575 private static void Tick ( TimeSpan window )
@@ -2595,7 +2597,10 @@ private static void Tick(TimeSpan window)
25952597 string [ ] toImport ;
25962598 lock ( _lock ) { toImport = _paths . ToArray ( ) ; _paths . Clear ( ) ; }
25972599 foreach ( var p in toImport )
2598- AssetDatabase . ImportAsset ( p , ImportAssetOptions . ForceUpdate ) ;
2600+ {
2601+ var sp = ManageScriptRefreshHelpers . SanitizeAssetsPath ( p ) ;
2602+ AssetDatabase . ImportAsset ( sp , ImportAssetOptions . ForceUpdate | ImportAssetOptions . ForceSynchronousImport ) ;
2603+ }
25992604#if UNITY_EDITOR
26002605 UnityEditor . Compilation . CompilationPipeline . RequestScriptCompilation ( ) ;
26012606#endif
@@ -2607,16 +2612,31 @@ private static void Tick(TimeSpan window)
26072612
26082613static class ManageScriptRefreshHelpers
26092614{
2615+ public static string SanitizeAssetsPath ( string p )
2616+ {
2617+ if ( string . IsNullOrEmpty ( p ) ) return p ;
2618+ p = p . Replace ( '\\ ' , '/' ) . Trim ( ) ;
2619+ if ( p . StartsWith ( "unity://path/" , StringComparison . OrdinalIgnoreCase ) )
2620+ p = p . Substring ( "unity://path/" . Length ) ;
2621+ while ( p . StartsWith ( "Assets/Assets/" , StringComparison . OrdinalIgnoreCase ) )
2622+ p = p . Substring ( "Assets/" . Length ) ;
2623+ if ( ! p . StartsWith ( "Assets/" , StringComparison . OrdinalIgnoreCase ) )
2624+ p = "Assets/" + p . TrimStart ( '/' ) ;
2625+ return p ;
2626+ }
2627+
26102628 public static void ScheduleScriptRefresh ( string relPath )
26112629 {
2612- RefreshDebounce . Schedule ( relPath , TimeSpan . FromMilliseconds ( 200 ) ) ;
2630+ var sp = SanitizeAssetsPath ( relPath ) ;
2631+ RefreshDebounce . Schedule ( sp , TimeSpan . FromMilliseconds ( 200 ) ) ;
26132632 }
26142633
26152634 public static void ImportAndRequestCompile ( string relPath , bool synchronous = true )
26162635 {
2636+ var sp = SanitizeAssetsPath ( relPath ) ;
26172637 var opts = ImportAssetOptions . ForceUpdate ;
26182638 if ( synchronous ) opts |= ImportAssetOptions . ForceSynchronousImport ;
2619- AssetDatabase . ImportAsset ( relPath , opts ) ;
2639+ AssetDatabase . ImportAsset ( sp , opts ) ;
26202640#if UNITY_EDITOR
26212641 UnityEditor . Compilation . CompilationPipeline . RequestScriptCompilation ( ) ;
26222642#endif
0 commit comments