UnityGame/Library/PackageCache/com.unity.collab-proxy/Editor/PlasticSCM/UI/EditorWindowFocus.cs

46 lines
1.1 KiB
C#
Raw Normal View History

2024-10-27 10:53:47 +03:00
using System;
using UnityEditor;
using UnityEditorInternal;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class EditorWindowFocus
{
internal static event Action OnApplicationActivated;
internal static event Action OnApplicationDeactivated;
static EditorWindowFocus()
{
EditorApplication.update += Update;
}
static void Update()
{
bool isApplicationActive = InternalEditorUtility.isApplicationActive;
if (!mLastIsApplicationFocused && isApplicationActive)
{
mLastIsApplicationFocused = isApplicationActive;
if (OnApplicationActivated != null)
OnApplicationActivated();
return;
}
if (mLastIsApplicationFocused && !isApplicationActive)
{
mLastIsApplicationFocused = isApplicationActive;
if (OnApplicationDeactivated != null)
OnApplicationDeactivated();
return;
}
}
static bool mLastIsApplicationFocused;
}
}