返回介绍

Screen.sleepTimeout 休眠超时

发布于 2019-12-18 15:38:30 字数 1862 浏览 1878 评论 0 收藏 0

JavaScript => public static var sleepTimeout: int;
C# => public static int sleepTimeout;

Description 描述

A power saving setting, allowing the 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.

sleepTimeout以秒计算,默认值根据不同的平台而不同,一般是非零值。

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.

在移动设备上,游戏使用加速度传感器作为主要输入源,设置sleepTimeout为SleepTimeout.NeverSleep,防止休眠。然而,此类游戏应该允许在菜单设置屏幕变暗或暂停时。

JavaScript:

	// Disable screen dimming
	Screen.sleepTimeout = SleepTimeout.NeverSleep;

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void Start() {
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
    }
}

Screen

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文