【Unity】监听GameView分辨率变化

发表于2017-08-28
评论0 2.6k浏览
很多人其实还不知道怎么获取GameView的分辨率,为此下面这篇文章就给大家介绍下监听GameView分辨率变化的方法,快来看看吧。

  1. using UnityEngine;  
  2. using System.Collections;  
  3.   
  4. [ExecuteInEditMode]  
  5. public class GameViewTest : MonoBehaviour  
  6. {  
  7.   
  8.     private float lastwidth = 0f;  
  9.     private float lastheight = 0f;  
  10.   
  11.     private void OnGUI()  
  12.     {  
  13.         if (lastwidth != Screen.width || lastheight != Screen.height)  
  14.         {  
  15.             lastwidth = Screen.width;  
  16.             lastheight = Screen.height;  
  17.             print("Resolution :"   Screen.width   " X"   Screen.height);  
  18.         }  
  19.     }  
  20. }  

如社区发表内容存在侵权行为,您可以点击这里查看侵权投诉指引

标签: