iPhone screen becomes dark while playing racing game

During the gameplay(car race), even though there is user interaction with the screen, the screen becomes dark after few minutes of gameplay(say 2-3 mins) and again get back to normal upon touching the screen, its a kind of user disruption Is there any solution, so that the iPhone screen will be in normal state, when user is intact with the screen?

Use this for Unity 3.4 version.


Screen.sleepTimeout = 0.0f;


In script change iPhoneSettings.screenCanDarken to false. This basically does the same as:

//Objective-C call [UIApplication sharedApplication].idleTimerDisabled = YES;

It prevents the auto lock on iPhone to kick-in.