@@ -1774,10 +1774,17 @@ public bool ParseManifests(FileMetadataByVersion metadataByVersion,
17741774 var obsoleteFilesSorted = new List < string > ( obsoleteFiles ) ;
17751775 currentFilesSorted . Sort ( ) ;
17761776 obsoleteFilesSorted . Sort ( ) ;
1777- Log ( String . Format ( "'{0}' Manifest:\n \n Current files:\n {1}\n \n Obsolete files:\n {2}" ,
1778- filenameCanonical ,
1779- String . Join ( "\n " , currentFilesSorted . ToArray ( ) ) ,
1780- String . Join ( "\n " , obsoleteFilesSorted . ToArray ( ) ) ) ,
1777+ var components = new List < string > ( ) ;
1778+ if ( currentFilesSorted . Count > 0 ) {
1779+ components . Add ( String . Format ( "Current files:\n {0}" ,
1780+ String . Join ( "\n " , currentFilesSorted . ToArray ( ) ) ) ) ;
1781+ }
1782+ if ( obsoleteFilesSorted . Count > 0 ) {
1783+ components . Add ( String . Format ( "Obsolete files:\n {0}" ,
1784+ String . Join ( "\n " , obsoleteFilesSorted . ToArray ( ) ) ) ) ;
1785+ }
1786+ Log ( String . Format ( "'{0}' Manifest:\n {1}" ,
1787+ filenameCanonical , String . Join ( "\n " , components . ToArray ( ) ) ) ,
17811788 verbose : true ) ;
17821789 return true ;
17831790 }
@@ -2148,6 +2155,13 @@ public static Logger Logger {
21482155 InstallSourceFilename = Assembly . GetAssembly ( typeof ( VersionHandlerImpl ) ) . Location
21492156 } ;
21502157
2158+ /// <summary>
2159+ /// Load log preferences.
2160+ /// </summary>
2161+ private static void LoadLogPreferences ( ) {
2162+ VerboseLoggingEnabled = VerboseLoggingEnabled ;
2163+ }
2164+
21512165 /// <summary>
21522166 /// Enables / disables assets imported at multiple revisions / versions.
21532167 /// In addition, this module will read text files matching _manifest_
@@ -2156,8 +2170,7 @@ public static Logger Logger {
21562170 static VersionHandlerImpl ( ) {
21572171 Log ( "Loaded VersionHandlerImpl" , verbose : true ) ;
21582172 RunOnMainThread . Run ( ( ) => {
2159- // Load log preferences.
2160- VerboseLoggingEnabled = VerboseLoggingEnabled ;
2173+ LoadLogPreferences ( ) ;
21612174 UpdateVersionedAssetsOnUpdate ( ) ;
21622175 } , runNow : false ) ;
21632176 }
@@ -2196,7 +2209,10 @@ private static bool EnabledEditorDllsLoaded {
21962209 var loadedAssemblyPaths = new HashSet < string > ( ) ;
21972210 foreach ( var assembly in AppDomain . CurrentDomain . GetAssemblies ( ) ) {
21982211 try {
2199- loadedAssemblyPaths . Add ( Path . GetFullPath ( assembly . Location ) ) ;
2212+ var path = Path . GetFullPath ( assembly . Location ) ;
2213+ if ( enabledEditorDlls . Contains ( path ) ) {
2214+ loadedAssemblyPaths . Add ( path ) ;
2215+ }
22002216 } catch ( NotSupportedException ) {
22012217 // Dynamic assemblies do not have a file location so ignore.
22022218 }
@@ -2432,6 +2448,7 @@ public static void ShowSettings() {
24322448 /// </summary>
24332449 [ MenuItem ( "Assets/External Dependency Manager/Version Handler/Update" ) ]
24342450 public static void UpdateNow ( ) {
2451+ LoadLogPreferences ( ) ;
24352452 UpdateVersionedAssets ( true , ( ) => {
24362453 Dialog . Display ( PLUGIN_NAME , "Update complete." , 0 , "OK" ) ;
24372454 } ) ;
@@ -2589,6 +2606,20 @@ public static void UpdateVersionedAssets(bool forceUpdate) {
25892606 /// <param name="forceUpdate">Whether to force an update.</param>
25902607 /// <param name="complete">Called when this is method is complete.</param>
25912608 public static void UpdateVersionedAssets ( bool forceUpdate , Action complete ) {
2609+ CancelUpdateVersionedAssets ( ) ;
2610+ RunOnMainThread . Run ( ( ) => { UpdateVersionedAssetsOnMainThread ( forceUpdate , complete ) ; } ,
2611+ runNow : false ) ;
2612+ }
2613+
2614+ /// <summary>
2615+ /// Find all files in the asset database with multiple version numbers
2616+ /// encoded in their filename, select the most recent revisions and
2617+ /// delete obsolete versions and files referenced by old manifests that
2618+ /// are not present in the most recent manifests.
2619+ /// </summary>
2620+ /// <param name="forceUpdate">Whether to force an update.</param>
2621+ /// <param name="complete">Called when this is method is complete.</param>
2622+ private static void UpdateVersionedAssetsOnMainThread ( bool forceUpdate , Action complete ) {
25922623 // If this module is disabled do nothing.
25932624 if ( ! forceUpdate && ! Enabled ) {
25942625 complete ( ) ;
@@ -2784,14 +2815,35 @@ public static float GetUnityVersionMajorMinor() {
27842815 return ExecutionEnvironment . VersionMajorMinor ;
27852816 }
27862817
2818+ // ID of the scheduled job which performs an update.
2819+ private static int updateVersionedAssetsJob = 0 ;
2820+
2821+ /// <summary>
2822+ /// Cancel the update versioned assets job.
2823+ /// </summary>
2824+ private static void CancelUpdateVersionedAssets ( ) {
2825+ if ( updateVersionedAssetsJob > 0 ) {
2826+ RunOnMainThread . Cancel ( updateVersionedAssetsJob ) ;
2827+ updateVersionedAssetsJob = 0 ;
2828+ }
2829+ }
2830+
27872831 /// <summary>
27882832 /// Scanned for versioned assets and apply modifications if required.
27892833 /// </summary>
27902834 private static void OnPostprocessAllAssets (
27912835 string [ ] importedAssets , string [ ] deletedAssets ,
27922836 string [ ] movedAssets , string [ ] movedFromPath ) {
27932837 ManifestReferences . FlushCaches ( ) ;
2794- UpdateVersionedAssets ( ) ;
2838+ if ( Enabled ) {
2839+ const double UpdateDelayInMiliseconds = 2000 ;
2840+ CancelUpdateVersionedAssets ( ) ;
2841+ updateVersionedAssetsJob =
2842+ RunOnMainThread . Schedule ( ( ) => {
2843+ UpdateVersionedAssets ( ) ;
2844+ } ,
2845+ UpdateDelayInMiliseconds ) ;
2846+ }
27952847 }
27962848
27972849 /// <summary>
0 commit comments