コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

EditorApplication.focusChanged や isFocused でエディタがフォーカスされているか確認できる

EditorApplication.focusChanged の使用例

using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
public static class Example
{
    static Example()
    {
        EditorApplication.focusChanged += isFocused =>
        {
            Debug.Log( isFocused );
        };
    }
}

EditorApplication.isFocused の使用例

using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
public static class Example
{
    static Example()
    {
        EditorApplication.update += () =>
        {
            Debug.Log( EditorApplication.isFocused );
        };
    }
}

参考サイト様