Skip to content

Instantly share code, notes, and snippets.

@tim-hub
Created April 7, 2016 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-hub/2ecaa1e2ef134f9866bf815761aefe48 to your computer and use it in GitHub Desktop.
Save tim-hub/2ecaa1e2ef134f9866bf815761aefe48 to your computer and use it in GitHub Desktop.
check long press on touch screen
bool CheckForLongPress() {
if (Input.touches[0].phase == TouchPhase.Began) { // If the user puts her finger on screen...
_timePressed = Time.time - _timeLastPress;
}
if (Input.touches[0].phase == TouchPhase.Ended) { // If the user raises her finger from screen
_timeLastPress = Time.time;
if (_timePressed > WaitingSeconds/2f) { // Is the time pressed greater than our time delay threshold?
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment