Created
April 7, 2016 06:21
-
-
Save tim-hub/2ecaa1e2ef134f9866bf815761aefe48 to your computer and use it in GitHub Desktop.
check long press on touch screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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