ソースコード
#if UNITY_EDITOR
using System;
using UnityEditor;
using UnityEngine;
namespace Kogane
{
[InitializeOnLoad]
public static class ScreenSizeChecker
{
public static event Action OnChanged;
static ScreenSizeChecker()
{
var oldWidth = Screen.width;
var oldHeight = Screen.height;
EditorApplication.update += () =>
{
var newWidth = Screen.width;
var newHeight = Screen.height;
if ( oldWidth != newWidth || oldHeight != newHeight )
{
OnChanged?.Invoke();
}
oldWidth = newWidth;
oldHeight = newHeight;
};
}
}
}
#endif