@@ -919,6 +919,17 @@ public void Add(FileMetadata metadata) {
919
919
/// <returns>true if any plugin metadata was modified and requires an
920
920
/// AssetDatabase.Refresh(), false otherwise.</return>
921
921
public bool EnableMostRecentPlugins ( ) {
922
+ return EnableMostRecentPlugins ( new HashSet < string > ( ) ) ;
923
+ }
924
+
925
+ /// <summary>
926
+ /// If this instance references a set of plugins, enable the most
927
+ /// recent versions.
928
+ /// </summary>
929
+ /// <param name="disableFiles">Set of files in the project that should be disabled.</param>
930
+ /// <returns>true if any plugin metadata was modified and requires an
931
+ /// AssetDatabase.Refresh(), false otherwise.</return>
932
+ public bool EnableMostRecentPlugins ( HashSet < string > disableFiles ) {
922
933
bool modified = false ;
923
934
int versionIndex = 0 ;
924
935
int numberOfVersions = metadataByVersion . Count ;
@@ -970,13 +981,16 @@ public bool EnableMostRecentPlugins() {
970
981
bool modifiedThisVersion = false ;
971
982
// Only enable the most recent plugin - SortedDictionary
972
983
// orders keys in ascending order.
973
- bool obsoleteVersion = ( numberOfVersions > 1 &&
974
- versionIndex < numberOfVersions ) ;
984
+ bool obsoleteVersion =
985
+ ( numberOfVersions > 1 && versionIndex < numberOfVersions ) ||
986
+ disableFiles . Contains ( metadata . filename ) ;
975
987
// If this is an obsolete version.
976
988
if ( obsoleteVersion ) {
977
989
// Disable for all platforms and the editor.
978
990
editorEnabled = false ;
979
991
selectedTargets = new HashSet < BuildTarget > ( ) ;
992
+ Log ( String . Format ( "{0} is obsolete and will be disabled." , metadata . filename ) ,
993
+ verbose : true ) ;
980
994
} else {
981
995
if ( hasDotNetTargets ) {
982
996
// Determine whether this is supported by the selected .NET version.
@@ -1055,6 +1069,8 @@ public bool EnableMostRecentPlugins() {
1055
1069
// Therefore, force a reimport of each file touched by the
1056
1070
// plugin importer.
1057
1071
if ( modifiedThisVersion ) {
1072
+ Log ( String . Format ( "Metadata changed: force import of {0}" , metadata . filename ) ,
1073
+ verbose : true ) ;
1058
1074
AssetDatabase . ImportAsset ( metadata . filename ,
1059
1075
ImportAssetOptions . ForceUpdate ) ;
1060
1076
}
@@ -1396,6 +1412,21 @@ public void ConsolidateManifests() {
1396
1412
/// <returns>true if any plugin metadata was modified and requires an
1397
1413
/// AssetDatabase.Refresh(), false otherwise.</return>
1398
1414
public bool EnableMostRecentPlugins ( bool forceUpdate ) {
1415
+ return EnableMostRecentPlugins ( forceUpdate , new HashSet < string > ( ) ) ;
1416
+ }
1417
+
1418
+ /// <summary>
1419
+ /// For each plugin (DLL) referenced by this set, disable targeting
1420
+ /// for all versions and re-enable platform targeting for the most
1421
+ /// recent version.
1422
+ /// </summary>
1423
+ /// <param name="forceUpdate">Whether the update was forced by the
1424
+ /// user.</param>
1425
+ /// <param name="disableFiles">Set of files that should be disabled.</param>
1426
+ /// <returns>true if any plugin metadata was modified and requires an
1427
+ /// AssetDatabase.Refresh(), false otherwise.</return>
1428
+ public bool EnableMostRecentPlugins ( bool forceUpdate ,
1429
+ HashSet < string > disableFiles ) {
1399
1430
bool modified = false ;
1400
1431
1401
1432
// If PluginImporter isn't available it's not possible
@@ -1474,7 +1505,7 @@ public bool EnableMostRecentPlugins(bool forceUpdate) {
1474
1505
}
1475
1506
1476
1507
foreach ( var metadataByVersion in Values ) {
1477
- modified |= metadataByVersion . EnableMostRecentPlugins ( ) ;
1508
+ modified |= metadataByVersion . EnableMostRecentPlugins ( disableFiles ) ;
1478
1509
}
1479
1510
return modified ;
1480
1511
}
@@ -1790,6 +1821,18 @@ public class ObsoleteFiles {
1790
1821
/// </summary>
1791
1822
public Dictionary < string , List < string > > referencedExcludingManifests ;
1792
1823
1824
+ /// <summary>
1825
+ /// Get all referenced and unreferenced obsolete files.
1826
+ /// </summary>
1827
+ public HashSet < string > All {
1828
+ get {
1829
+ var all = new HashSet < string > ( ) ;
1830
+ all . UnionWith ( unreferenced ) ;
1831
+ all . UnionWith ( referenced . Keys ) ;
1832
+ return all ;
1833
+ }
1834
+ }
1835
+
1793
1836
/// <summary>
1794
1837
/// Build an ObsoleteFiles instance searching a set of
1795
1838
/// ManifestReferences and a FileMetadataSet for old files.
@@ -2401,15 +2444,15 @@ public static void UpdateVersionedAssets(bool forceUpdate, Action complete) {
2401
2444
if ( ! forceUpdate ) {
2402
2445
metadataSet = FileMetadataSet . FindWithPendingUpdates ( metadataSet ) ;
2403
2446
}
2404
- if ( metadataSet . EnableMostRecentPlugins ( forceUpdate ) ) {
2447
+
2448
+ var obsoleteFiles = new ObsoleteFiles (
2449
+ ManifestReferences . FindAndReadManifests ( metadataSet ) , metadataSet ) ;
2450
+ if ( metadataSet . EnableMostRecentPlugins ( forceUpdate , obsoleteFiles . All ) ) {
2405
2451
analytics . Report ( "enablemostrecentplugins" , "Enable Most Recent Plugins" ) ;
2406
2452
AssetDatabase . Refresh ( ) ;
2407
2453
Refreshing = true ;
2408
2454
}
2409
2455
2410
- var obsoleteFiles = new ObsoleteFiles (
2411
- ManifestReferences . FindAndReadManifests ( metadataSet ) , metadataSet ) ;
2412
-
2413
2456
// Obsolete files that are no longer referenced can be safely deleted, prompt the user for
2414
2457
// confirmation if they have the option enabled.
2415
2458
var cleanupFiles = new List < KeyValuePair < string , string > > ( ) ;
0 commit comments