How do I stop the screen turning off on an android. I can stop the screen going dim but not to stop turning it off. My game uses the accelerometer.
Thanks
How do I stop the screen turning off on an android. I can stop the screen going dim but not to stop turning it off. My game uses the accelerometer.
Thanks
You should use:
Screen.sleepTimeout = SleepTimeout.NeverSleep;
this script does both
iPhoneSettings.screenCanDarken = false;
The iPhoneSettings.screenCanDarken is deprecated - it’s now
Screen.sleepTimeout = 0f;
0 is never darken, other values in seconds - docs here
My Asus ignoring or forget sigle command and stoutly get screen twice darker after a minute.
In some little expeiments ive got a solution:
Screen.sleepTimeout = (int)0f;
Screen.sleepTimeout = SleepTimeout.NeverSleep;
in void Update () section, somehow wakes it nonsop.
// Prevent screen dimming.
public const int NeverSleep = -1;
//
// Set the sleep timeout to whatever the user has specified in the system settings.
public const int SystemSetting = -2;
I found this on source code so if you want make it never sleep you should use -1 instead of 0
and -2 for system default value if you changed it to any different value.
But I recomend
Screen.sleepTimeout = SleepTimeout.NeverSleep; as Macarse said. You can hover over neverSleep to see -1 value by yourself .
Just wanted to make it clear 0 is not the true answer for never sleep it is -1
@Macarse I am using
Screen.sleepTimeout = SleepTimeout.NeverSleep;
but Not being able to prevent device sleep in Webgl Mobile platform.
is there some other way for this or am I missing something.
Please help me out.