Unity에서 GameView 사이즈를 키보드로 조절할 수 있는 class입니다.
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public class ResolutionManager : MonoBehaviour
{
#if UNITY_EDITOR
private void Update()
{
if (Input.GetKeyDown(KeyCode.P))
{
SetSize(11);
Debug.LogWarning("세로모드");
}
if(Input.GetKeyDown(KeyCode.L))
{
SetSize(12);
Debug.LogWarning("가로모드");
}
}
#endif
#if UNITY_EDITOR
public static void SetSize(int index)
{
var gvWndType = typeof(Editor).Assembly.GetType("UnityEditor.GameView");
var gvWnd = EditorWindow.GetWindow(gvWndType);
var SizeSelectionCallback = gvWndType.GetMethod("SizeSelectionCallback",
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
SizeSelectionCallback.Invoke(gvWnd, new object[] { index, null });
}
#endif
}