- Home /
Input touch doesn't detect native keyboard
I have set my App to go to a 'screensaver' scene if it doesn't detect any touch input for 60 secs.
However, this doesn't seem to work if the user is typing (in an InputField) with the native keyboard; even if they are typing, it will go to the screensaver scene after 60 secs.
This is my script:
public float timeOut = 30.0f;
private float timeOutTimer = 0.0f;
void Update(){
timeOutTimer += Time.deltaTime;
if (Input.touchCount > 0){
timeOutTimer = 0.0f;
}
if (timeOutTimer > timeOut) {
SceneManager.LoadScene("AttractorScene");
}
}
}
Answer by Hellium · Aug 19, 2019 at 09:52 AM
I believe it's the expected behaviour. Input.TouchCount
surely register touches within the game itself. However, the keyboard is not part of Unity, which explains the current behaviour.
I suggest you to have a ResetTimer
function you will be able to call from the onValueChange
event of the InputField component.
void Update(){
timeOutTimer += Time.deltaTime;
if (Input.touchCount > 0){
ResetTimer();
}
if (timeOutTimer > timeOut) {
SceneManager.LoadScene("AttractorScene");
}
}
}
// Specify this function in the `onEndEdit` event of the InputField component
public void ResetTimer()
{
timeOutTimer = 0.0f;
}
Your answer
Follow this Question
Related Questions
XR Toolkit InputField Keyboard for Quest 2 Answers
[Android] Keyboard doesn't show immediately when selecting inputfield as S Pan. 1 Answer
Holotoolkit on screen keyboard won't open,Hololens on-screen keyboard won't open 1 Answer
Switching keyboard types on iPad when switching between 2 input fields. 2 Answers
How to make floating mobile keyboard in mobile game ? 0 Answers