Application类

作者:追风剑情 发布于:2020-7-17 11:10 分类:Unity3d

一、请求权限

Application.RequestUserAuthorization(UserAuthorization.WebCam);//请求摄像头权限
Application.RequestUserAuthorization(UserAuthorization.Microphone);//请求麦克风权限

二、限制帧率


1111.png

22222.png

先在 Quality 矩阵中选中要发布的平台和质量级别,再设置对应的 VSync Count 选项。

关闭垂直同步(Edit->Project Settings->Quality->VSync Count)

//允许后台运行
Application.runInBackground = true;
//禁止睡眠
Screen.sleepTimeout = SleepTimeout.NeverSleep; 
//设置帧率
Application.targetFrameRate = 60;
//关闭垂直同步,让游戏按照指定帧率运行,否则游戏会按设备支持的最大帧率运行
QualitySettings.vSyncCount = 0;
 

三、判断场景坐标是否落在屏幕内

//判断目标坐标是否落在屏幕内
Vector3 screenPoint = Camera.main.WorldToScreenPoint(target.position);
bool inScreen = screenPoint.x >= 0 && screenPoint.y >= 0 &&
	screenPoint.x <= Screen.width && screenPoint.y <= Screen.height &&
	screenPoint.z > 0;

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号