【Unity】监听GameView分辨率变化
发表于2017-08-28
很多人其实还不知道怎么获取GameView的分辨率,为此下面这篇文章就给大家介绍下监听GameView分辨率变化的方法,快来看看吧。
- using UnityEngine;
- using System.Collections;
- [ExecuteInEditMode]
- public class GameViewTest : MonoBehaviour
- {
- private float lastwidth = 0f;
- private float lastheight = 0f;
- private void OnGUI()
- {
- if (lastwidth != Screen.width || lastheight != Screen.height)
- {
- lastwidth = Screen.width;
- lastheight = Screen.height;
- print("Resolution :" Screen.width " X" Screen.height);
- }
- }
- }
