Singularity/Library/PackageCache/com.unity.collab-proxy@2.0.3/Editor/PlasticSCM/UI/EditorWindowFocus.cs

46 lines
1.1 KiB
C#
Raw Permalink Normal View History

2024-05-06 14:45:45 -04: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;
}
}