コガネブログ

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

【Unity】Game ビューの解像度のインデックスを取得する例

概要

const BindingFlags bindingAttrs = BindingFlags.Instance | BindingFlags.Public;

var gameViewType          = Type.GetType( "UnityEditor.GameView,UnityEditor" );
var selectedSizeIndexInfo = gameViewType!.GetProperty( "selectedSizeIndex", bindingAttrs );
var editorWindow          = EditorWindow.GetWindow( gameViewType );
var selectedSizeIndex     = selectedSizeIndexInfo!.GetValue( editorWindow );

Debug.Log( selectedSizeIndex );