A game about forced loneliness, made by TACStudios
1using UnityEditor; 2using UnityEditor.PackageManager; 3using Unity.PlasticSCM.Editor.UI; 4 5using AssetPostprocessor = Unity.PlasticSCM.Editor.AssetUtils.Processor.AssetPostprocessor; 6 7namespace Unity.PlasticSCM.Editor.AssetUtils 8{ 9 internal static class RefreshAsset 10 { 11 internal static void BeforeLongAssetOperation() 12 { 13 AssetDatabase.DisallowAutoRefresh(); 14 } 15 16 internal static void AfterLongAssetOperation() 17 { 18 AfterLongAssetOperation(true); 19 } 20 21 internal static void AfterLongAssetOperation(bool isPackagesReimportNeeded) 22 { 23 AssetDatabase.AllowAutoRefresh(); 24 25 if (isPackagesReimportNeeded) 26 { 27 UnityAssetDatabaseAndPackageManagerAsync(); 28 } 29 else 30 { 31 RefreshUnityAssetDatabase(); 32 } 33 } 34 35 internal static void UnityAssetDatabase() 36 { 37 RefreshUnityAssetDatabase(); 38 } 39 40 internal static void UnityAssetDatabaseAndPackageManagerAsync() 41 { 42 // Client.Resolve() will resolve any pending packages added or removed from the project 43 // VCS-1004718 - This is important so the domain gets reloaded first if needed 44 Client.Resolve(); 45 46 mCooldownRefreshAssetsAction.Ping(); 47 } 48 49 internal static void VersionControlCache() 50 { 51 ClearVersionControlCaches(); 52 53 ProjectWindow.Repaint(); 54 RepaintInspector.All(); 55 } 56 57 static void ClearVersionControlCaches() 58 { 59 UnityEditor.VersionControl.Provider.ClearCache(); 60 61 if (PlasticPlugin.AssetStatusCache != null) 62 PlasticPlugin.AssetStatusCache.Clear(); 63 } 64 65 static void RefreshUnityAssetDatabase() 66 { 67 AssetDatabase.Refresh(ImportAssetOptions.Default); 68 69 ClearVersionControlCaches(); 70 71 AssetPostprocessor.SetIsRepaintNeededAfterAssetDatabaseRefresh(); 72 } 73 74 static CooldownWindowDelayer mCooldownRefreshAssetsAction = new CooldownWindowDelayer( 75 RefreshUnityAssetDatabase, 76 UnityConstants.REFRESH_ASSET_DATABASE_DELAYED_INTERVAL); 77 } 78}