ソースコード
#if UNITY_EDITOR using System; using UnityEditor; namespace Kogane { public struct SetPlayModeWindowCustomRenderingResolutionScope : IDisposable { private readonly uint m_width; private readonly uint m_height; private bool m_isInitialized; public SetPlayModeWindowCustomRenderingResolutionScope ( uint width, uint height ) : this ( width: width, height: height, baseName: $"{width}x{height}" ) { } public SetPlayModeWindowCustomRenderingResolutionScope ( uint width, uint height, string baseName ) { PlayModeWindow.GetRenderingResolution ( out m_width, out m_height ); PlayModeWindow.SetCustomRenderingResolution ( width: width, height: height, baseName: baseName ); m_isInitialized = true; } public void Dispose() { if ( !m_isInitialized ) return; m_isInitialized = false; PlayModeWindow.SetCustomRenderingResolution ( width: m_width, height: m_height, baseName: $"{m_width}x{m_height}" ); } } } #endif