- Home /
Problem with touch and ui button
Just like the image above, we have a model and a canvas in front of it. It have collider at foots, and i need onclick event in the button also. What i want is the gameobject no action when user click button, but now it's hard to click the button.
Here is my code below:
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
EventSystem es = EventSystem.current;
if (es.IsPointerOverGameObject(Input.GetTouch(0).fingerId) && es.currentSelectedGameObject != null)
{
Debug.Log("Handle touch === ");
HandleTouchEvent();
}
}
Does someone has any ideas?
Answer by Magicware · Jan 12, 2017 at 10:36 AM
Not sure if this helps, but check this out, sounds familiar: http://answers.unity3d.com/questions/868618/problem-with-touch-and-raycast-and-ui-button.html
Your answer
Follow this Question
Related Questions
Problem with touch and ui button 5 Answers
How to prevent touch passing through UI ? 0 Answers
Trouble with "Creating Screen Transitions" UI How To 0 Answers
Advanced Unity: Custom touch input origin 1 Answer
Low screen sensitivity on Mobile 3 Answers