- Home /
TouchPhase.Began triggering twice
I have a bool function called by OnGUI, returning true if you are pressing a certain region on the screen and touch.phase == TouchPhase.Began. However, it returns true two times for each touch.
I guess this is caused by the OnGUI method being triggered more frequently than the Update function.
Is there a simple way to fix / work around the problem?
Answer by Jeff-Kesselman · May 15, 2014 at 06:13 PM
OnGUI gets called numerous times, once for each event this frame. You need to check the event it is currently processing.
https://docs.unity3d.com/Documentation/ScriptReference/Event.html
But consider doing Input processing in Update, not OnGUI. Just set some variables and render in OnGUI based on them.
Your answer
Follow this Question
Related Questions
Detect Long Press and single tap to make higher jumps 0 Answers
iPhone Touch Screen? 2 Answers
Touch phase returning incorrect results 1 Answer
Check whether touch is held 0 Answers
Custom touch phase? 0 Answers