- Home /
Question by
sijingsijinglin · Jun 08, 2018 at 09:01 PM ·
mobilecrashtouchscreen
Problem about detecting screen touch on mobile app.
Hello everyone,
How do you guys do to handle a screen touch in your project? Is there a simple way to detect a screen touch on mobile app and do a single action?
I am stuck at this problem for days. What I want to do is, on mobile app, make a menu disappear or show up via a ToggeleController() method, each time the screen get touched.
I have tried two different ways below.
1)
void Update(){ if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){ if (!EventSystem.current.IsPointerOverGameObject ()) { ToggeleController(); } flag = false; } }
There is no change at all. I guess it's probably because update() method runs every frame?
2)
void OnMouseDown(){//didn't work for android, inly half of the screen is clickable for toggele feature
if (!EventSystem.current.IsPointerOverGameObject ()) {
Debug.Log("Mouse Down!!");
ToggeleController();
}
flag = false;
}
The problem is only half of the screen is clickable.
Comment