Unity 入门操作 之 快速学会游戏运行不自动锁屏

 时间:2024-10-12 20:07:25

Unity 入门操作 之 快速学会游戏运行不自动锁屏。游戏运行时由于手机设置,手机会自动锁屏,手机的自动锁屏影响了游戏的体验度,本节讲解如何在自己游戏运行时,不自动锁屏的操作,具体如下

工具/原料

Unity

一、基本概念

1、Screen.sleepTimeout:A power saving setting, allowing t茑霁酌绡he screen to dim some time after the last active user interaction.Most useful for handheld devices, allowing OS to preserve battery life in most efficient ways. Does nothing on non-handheld devices.sleepTimeout is measured in seconds. The default value varies from platform to platform, generally being non-zero.On mobile devices it would be useful to set sleepTimeout to [SleepTimeout.NeverSleep] for games using accelerometer as the main source of input. However, such games should allow screen dimming while in menu or paused. Currently you will only be able to set this property to one of the values predefined in [SleepTimeout] class. A get will return either one of the predefined values, or the actual number of seconds until screen gets dimmed, as specified in system preferences of the device.

二、入门操作 之 快速学会游戏运行不自动锁屏

1、打开Unity,新建一个空工程,然后Unity界面如下图

Unity 入门操作 之 快速学会游戏运行不自动锁屏

3、选中“SleepTest”脚本,双击脚本或者右键“Open C# Project”,打开脚本,具体如下图

Unity 入门操作 之 快速学会游戏运行不自动锁屏

5、脚本编译正确后,回到Unity界面,在场景中新建一个“Cube”,然后把脚本“SleepTest”赋给“Cube”,具体如下图

Unity 入门操作 之 快速学会游戏运行不自动锁屏

7、到此,《Unity 入门操作 之 快速学会游戏运行不自动锁屏》讲解结束,谢谢

  • unity 脚本中如何获得另外物体的数据
  • microsoft edge怎么改默认网页
  • 求生无限攻略3
  • ANSYS热分析教程:热分析简介
  • 僵尸世界大战pc如何联机
  • 热门搜索
    子宫前位是什么意思 are是什么意思 adas是什么意思 土斤念什么 画漫画用什么笔 半信半疑的意思 落寞的意思 破折号有哪些作用 去痘印用什么 itunes是什么意思