@@ -1774,10 +1774,17 @@ public bool ParseManifests(FileMetadataByVersion metadataByVersion,
1774
1774
var obsoleteFilesSorted = new List < string > ( obsoleteFiles ) ;
1775
1775
currentFilesSorted . Sort ( ) ;
1776
1776
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 ( ) ) ) ,
1781
1788
verbose : true ) ;
1782
1789
return true ;
1783
1790
}
@@ -2148,6 +2155,13 @@ public static Logger Logger {
2148
2155
InstallSourceFilename = Assembly . GetAssembly ( typeof ( VersionHandlerImpl ) ) . Location
2149
2156
} ;
2150
2157
2158
+ /// <summary>
2159
+ /// Load log preferences.
2160
+ /// </summary>
2161
+ private static void LoadLogPreferences ( ) {
2162
+ VerboseLoggingEnabled = VerboseLoggingEnabled ;
2163
+ }
2164
+
2151
2165
/// <summary>
2152
2166
/// Enables / disables assets imported at multiple revisions / versions.
2153
2167
/// In addition, this module will read text files matching _manifest_
@@ -2156,8 +2170,7 @@ public static Logger Logger {
2156
2170
static VersionHandlerImpl ( ) {
2157
2171
Log ( "Loaded VersionHandlerImpl" , verbose : true ) ;
2158
2172
RunOnMainThread . Run ( ( ) => {
2159
- // Load log preferences.
2160
- VerboseLoggingEnabled = VerboseLoggingEnabled ;
2173
+ LoadLogPreferences ( ) ;
2161
2174
UpdateVersionedAssetsOnUpdate ( ) ;
2162
2175
} , runNow : false ) ;
2163
2176
}
@@ -2196,7 +2209,10 @@ private static bool EnabledEditorDllsLoaded {
2196
2209
var loadedAssemblyPaths = new HashSet < string > ( ) ;
2197
2210
foreach ( var assembly in AppDomain . CurrentDomain . GetAssemblies ( ) ) {
2198
2211
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
+ }
2200
2216
} catch ( NotSupportedException ) {
2201
2217
// Dynamic assemblies do not have a file location so ignore.
2202
2218
}
@@ -2432,6 +2448,7 @@ public static void ShowSettings() {
2432
2448
/// </summary>
2433
2449
[ MenuItem ( "Assets/External Dependency Manager/Version Handler/Update" ) ]
2434
2450
public static void UpdateNow ( ) {
2451
+ LoadLogPreferences ( ) ;
2435
2452
UpdateVersionedAssets ( true , ( ) => {
2436
2453
Dialog . Display ( PLUGIN_NAME , "Update complete." , 0 , "OK" ) ;
2437
2454
} ) ;
@@ -2589,6 +2606,20 @@ public static void UpdateVersionedAssets(bool forceUpdate) {
2589
2606
/// <param name="forceUpdate">Whether to force an update.</param>
2590
2607
/// <param name="complete">Called when this is method is complete.</param>
2591
2608
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 ) {
2592
2623
// If this module is disabled do nothing.
2593
2624
if ( ! forceUpdate && ! Enabled ) {
2594
2625
complete ( ) ;
@@ -2784,14 +2815,35 @@ public static float GetUnityVersionMajorMinor() {
2784
2815
return ExecutionEnvironment . VersionMajorMinor ;
2785
2816
}
2786
2817
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
+
2787
2831
/// <summary>
2788
2832
/// Scanned for versioned assets and apply modifications if required.
2789
2833
/// </summary>
2790
2834
private static void OnPostprocessAllAssets (
2791
2835
string [ ] importedAssets , string [ ] deletedAssets ,
2792
2836
string [ ] movedAssets , string [ ] movedFromPath ) {
2793
2837
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
+ }
2795
2847
}
2796
2848
2797
2849
/// <summary>
0 commit comments