Despite SleepTimeout.NeverSleep, screen still dims on android

I have
Screen.sleepTimeout = SleepTimeout.NeverSleep;
(Unity - Scripting API: Screen.sleepTimeout)

in one of my scripts, yet on Android the screen still dims if it wasn’t touch for a short while, any idea why this is? Happened on a fairly new device - Galaxy S9

Thanks!

Not sure. It’s possible the device settings can still overwrite the app settings on certain versions of the Android OS. I prefer my power saving settings to kick in and wouldn’t want the game to always stay up personally. I know Samsung also has its Game Launcher which has a screen lock feature that looks like a dim, but I don’t think it’s exactly the same thing. I use it all the time. You can set the lock manually or have it lock after x amount of time.

1 Like

Same here. Working with Unity 2021.3.7f1 and and Honor 10.
I set Screen.sleepTimeout = SleepTimeout.NeverSleep in awake() and start(), but the screen still dimms.

Any ideas?

The dimming of the screen is not really directly related to the sleep timeout. The sleep timeout defines when the phone should go in sleep mode. It’s true that most phones start dimming the screen before actually going to sleep. However the phone may dim your screen for various of reasons. Here’s an article that shows 5 of them. Note that some setting you can not change as an app as they are controlled by the OS and the user of the device.

edit
You may have a look over here. Here’s an old SO question that uses this approach. Though it may be outdated, but it looks like it should still work. Took about 2 minutes of searching and reading which is one of the main tasks you have as a programmer / developer :slight_smile: