- Home /
Screensaver when device is idle
Hi, I'm developing an App that will be on both iOS and Android and was wondering if someone could point me in the direction of how to create a screensaver.
Something along the lines of: if no input has been detected in x time, SetActive(true) screensaver graphic. If input is detected, SetActive (false) screensaver graphic.
I know I could do the latter part with a simple OnClick() function but it's the start I can't quite figure out.
Answer by hollym16 · Jun 08, 2016 at 03:22 PM
Ive found a solution that incorporates a Raycast hit detection (as opposed to a mouse click):
public float timeOut = 20.0f; // Time Out Setting in Seconds
private float timeOutTimer = 0.0f;
void Update(){
timeOutTimer += Time.deltaTime;
// If screen is tapped, reset timer
if(Input.GetMouseButtonDown(0)){
timeOutTimer = 0.0f;
//Dont active screensaver
}
// If timer reaches zero, start screensaver
if (timeOutTimer > timeOut){
//Activate Screensaver
}
}
}
Your answer
Follow this Question
Related Questions
Access the system time on mobile 1 Answer
Rigidbody or CharacterController for mobile 3d person shooter ? 0 Answers
Detect Orientation change at runtime? 0 Answers
Texture compression artifacts on iOS 0 Answers