I’m currently having problem with clicking a GUITexture on iPad
My plan is to use a single code that works fine both on PC/Mac and deployment target(iPad).
The problem is that when Unity pass Input.GetMouseButtonDown(0) as true and input.mousePosition to respond at wherever I tap on the screen.
So onto my code here:
if (someGuiTexture.HitTest(Input.mousePosition) || ( Input.touchCount >0 && Input.GetTouch(0).phase == TouchPhase.Began && someGUITexture.HitTest(touches[0].position)) { // Do something }
Looks fine isn’t it? It works OK on windows/mac, but the problem is when it’s deployed on iPad.
I give a check Input.GetTouch(0).phase == TouchPhase.Began
so it can only respond at the very first moment I touch the GUITexture. However, the previous check someGuiTexture.HitTest(Input.mousePosition)
gives the same result as someGUITexture.HitTest(touches[0].position)
.
I tried to change the PC/Mac input check into (Input.GetMouseButtonDown(0) && someGuiTexture.HitTest(Input.mousePosition))
and expecting the GetMouseButonDown(0) will always return false when I’m doing it on iPad, but no, it returns true.
So how do you guys usually solve/make a work around on this problem?