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.

EditorWindowFocus.cs 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using UnityEditor;
  3. using UnityEditorInternal;
  4. namespace Unity.PlasticSCM.Editor.UI
  5. {
  6. internal static class EditorWindowFocus
  7. {
  8. internal static event Action OnApplicationActivated;
  9. internal static event Action OnApplicationDeactivated;
  10. static EditorWindowFocus()
  11. {
  12. EditorApplication.update += Update;
  13. }
  14. static void Update()
  15. {
  16. bool isApplicationActive = InternalEditorUtility.isApplicationActive;
  17. if (!mLastIsApplicationFocused && isApplicationActive)
  18. {
  19. mLastIsApplicationFocused = isApplicationActive;
  20. if (OnApplicationActivated != null)
  21. OnApplicationActivated();
  22. return;
  23. }
  24. if (mLastIsApplicationFocused && !isApplicationActive)
  25. {
  26. mLastIsApplicationFocused = isApplicationActive;
  27. if (OnApplicationDeactivated != null)
  28. OnApplicationDeactivated();
  29. return;
  30. }
  31. }
  32. static bool mLastIsApplicationFocused;
  33. }
  34. }