- Home /
Wake lock for android
I'm creating a game for android that uses only accelerometer, so the users don't touch the screen. After a time playing, the screens locks. I don't want the auto lock while the player is inside the gameplay.
How to do that in unity? I tried to write in the manifest: But it don't works...
I know this is a month old, but I would still like to see an answer... I have an identical situation.
Answer by Moj · Jun 18, 2012 at 07:11 AM
I'm guessing you've solved this by now. The Unity Reference has the example you're looking for. Prevents auto lock on my Galaxy S2.
// Disable screen dimming
Screen.sleepTimeout = SleepTimeout.NeverSleep;
http://unity3d.com/support/documentation/ScriptReference/Screen-sleepTimeout
Answer by NiklasK · Nov 21, 2011 at 04:26 PM
I have the same problems.
I have also tried:
Screen.sleepTimeout = 0.0f;
and
iPhoneSettings.screenCanDarken = false;
even tho it is obsolete. This works fine for a few devices, but not our Galaxy TAB. Tested devices is Galaxy S1/S2, Xperia PLAY and Galaxy TAB. Maby one of these options works for you.