Bez popisu
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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. UnityAssetDatabaseAndPackageManagerAsync();
  17. }
  18. internal static void UnityAssetDatabase()
  19. {
  20. RefreshUnityAssetDatabase();
  21. }
  22. internal static void UnityAssetDatabaseAndPackageManagerAsync()
  23. {
  24. // Client.Resolve() will resolve any pending packages added or removed from the project
  25. // VCS-1004718 - This is important so the domain gets reloaded first if needed
  26. Client.Resolve();
  27. mCooldownRefreshAssetsAction.Ping();
  28. }
  29. internal static void VersionControlCache()
  30. {
  31. ClearVersionControlCaches();
  32. ProjectWindow.Repaint();
  33. RepaintInspector.All();
  34. }
  35. static void ClearVersionControlCaches()
  36. {
  37. UnityEditor.VersionControl.Provider.ClearCache();
  38. if (PlasticPlugin.AssetStatusCache != null)
  39. PlasticPlugin.AssetStatusCache.Clear();
  40. }
  41. static void RefreshUnityAssetDatabase()
  42. {
  43. AssetDatabase.Refresh(ImportAssetOptions.Default);
  44. ClearVersionControlCaches();
  45. AssetPostprocessor.SetIsRepaintNeededAfterAssetDatabaseRefresh();
  46. }
  47. static CooldownWindowDelayer mCooldownRefreshAssetsAction = new CooldownWindowDelayer(
  48. RefreshUnityAssetDatabase,
  49. UnityConstants.REFRESH_ASSET_DATABASE_DELAYED_INTERVAL);
  50. }
  51. }