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:
sleepTimeout is set to SleepTimeout.SystemSetting. The device locks as normal when you launch the app from the home screen.sleepTimeout to SleepTimeout.SystemSetting, the display and the system sleep according to the user's sleep settings in macOS. The getter only returns SleepTimeout.NeverSleep or SleepTimeout.SystemSetting.sleepTimeout always returns SleepTimeout.NeverSleep, and setting it has no effect.using UnityEngine;
public class Example : MonoBehaviour { void Start() { // Disable screen dimming Screen.sleepTimeout = SleepTimeout.NeverSleep; } }
Additional resources: SleepTimeout.