Version: Unity 6.3 LTS (6000.3)
LanguageEnglish
  • C#

Screen.sleepTimeout

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static int sleepTimeout;

Description

A power-saving setting that lets the screen dim after a period of user inactivity.

This setting is most useful for handheld devices, as it lets the operating system preserve battery life.

On mobile devices that use the accelerometer as the main source of input, consider setting sleepTimeout to SleepTimeout.NeverSleep during gameplay, and restoring SleepTimeout.SystemSetting in menus or while the game is paused.

The valid values are SleepTimeout.NeverSleep and SleepTimeout.SystemSetting. Unity doesn't support setting a fixed number of seconds. Unity treats any other value as SleepTimeout.SystemSetting. The default value and the value the getter returns vary by platform:

using UnityEngine;

public class Example : MonoBehaviour { void Start() { // Disable screen dimming Screen.sleepTimeout = SleepTimeout.NeverSleep; } }

Additional resources: SleepTimeout.