Skip to content

Commit a6d91a5

Browse files
committed
Scenes in read-only packages aren't searched since they can't be opened (fixed #36) (closed #37)
1 parent ace8ac4 commit a6d91a5

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,18 +514,29 @@ public SearchResult Run( Parameters searchParameters )
514514
}
515515
}
516516

517+
// Search scenes for references
517518
foreach( string scenePath in scenesToSearch )
518519
{
519520
if( EditorUtility.DisplayCancelableProgressBar( "Please wait...", "Searching scene: " + scenePath, (float) ++searchProgress / searchTotalProgress ) )
520521
throw new Exception( "Search aborted" );
521522

522-
// Search scene for references
523523
if( string.IsNullOrEmpty( scenePath ) )
524524
continue;
525525

526526
if( excludedScenesPathsSet.Contains( scenePath ) )
527527
continue;
528528

529+
#if UNITY_2019_2_OR_NEWER
530+
// Skip scenes in read-only packages (Issue #36)
531+
// Credit: https://forum.unity.com/threads/check-if-asset-inside-package-is-readonly.900902/#post-5990822
532+
if( !scenePath.StartsWithFast( "Assets/" ) )
533+
{
534+
var packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath( scenePath );
535+
if( packageInfo != null && packageInfo.source != UnityEditor.PackageManager.PackageSource.Embedded && packageInfo.source != UnityEditor.PackageManager.PackageSource.Local )
536+
continue;
537+
}
538+
#endif
539+
529540
SearchScene( scenePath, searchResult, searchParameters, initialSceneSetup );
530541
}
531542
}

0 commit comments

Comments
 (0)