No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RefreshAsset.cs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using UnityEditor.PackageManager;
  2. using UnityEditor;
  3. using AssetPostprocessor = Unity.PlasticSCM.Editor.AssetUtils.Processor.AssetPostprocessor;
  4. using Unity.PlasticSCM.Editor.UI;
  5. namespace Unity.PlasticSCM.Editor.AssetUtils
  6. {
  7. internal static class RefreshAsset
  8. {
  9. internal static void BeforeLongAssetOperation()
  10. {
  11. AssetDatabase.DisallowAutoRefresh();
  12. }
  13. internal static void AfterLongAssetOperation()
  14. {
  15. AssetDatabase.AllowAutoRefresh();
  16. // Client.Resolve() will resolve any pending packages added or removed from the project
  17. // VCS-1004718 - This is important so the domain gets reloaded first if needed
  18. Client.Resolve();
  19. mCooldownRefreshAssetsAction.Ping();
  20. }
  21. internal static void UnityAssetDatabase()
  22. {
  23. RefreshUnityAssetDatabase();
  24. }
  25. internal static void VersionControlCache()
  26. {
  27. ClearVersionControlCaches();
  28. ProjectWindow.Repaint();
  29. RepaintInspector.All();
  30. }
  31. static void ClearVersionControlCaches()
  32. {
  33. UnityEditor.VersionControl.Provider.ClearCache();
  34. if (PlasticPlugin.AssetStatusCache != null)
  35. PlasticPlugin.AssetStatusCache.Clear();
  36. }
  37. static void RefreshUnityAssetDatabase()
  38. {
  39. AssetDatabase.Refresh(ImportAssetOptions.Default);
  40. ClearVersionControlCaches();
  41. AssetPostprocessor.SetIsRepaintNeededAfterAssetDatabaseRefresh();
  42. }
  43. static CooldownWindowDelayer mCooldownRefreshAssetsAction = new CooldownWindowDelayer(
  44. RefreshUnityAssetDatabase,
  45. UnityConstants.REFRESH_ASSET_DATABASE_DELAYED_INTERVAL);
  46. }
  47. }