- Home /
Cant't recognize touch on iOS, but on Android and Mac it's ok
Hi, have a problem.
trying to deploy ma unity app on the iphone, but there is a problem. i have one scene, where you are clicking on objects and the objects playing sounds after click. Everything going just fine on the Android device and the Mac, but on iPhone it seems, like it's not listening to the touches on the screen... tested on the iphone 4G, iphone 5S and ipad air 3, same results..
this problem occurs yesterday, before that it was fine on all tested platforms..
any advices please?
thank you very much
You might want to show us some of your touch-handling code so we can figure out what is wrong
hi razacx, for me its clear that there is not problem in touching event, because i havent change it and before yesterday everything worked ok.
can be there some problem with my settings of unity player setting or xcode?
Input.GetTouch()
is known to work. Typically you use the touch position, and fire a ray into the scene to work out what it hits. Hard to see how that can't work. Where I have seen people have problems is where they use Unity's mouse handling code and scale GUIs.
I'm using this code for recognizing the touch of objects
foreach (Touch touch in Input.touches) {
if (touch.phase == TouchPhase.Began) {
RaycastHit hitInfo = GetObject (touch.position);
if (hitInfo.collider != null) {
if (hitInfo.collider.tag.Equals ("Instrument")) {
Instrument script = hitInfo.collider.gameObject.GetComponent ();
if (script != null) {
script.Hit ();
}
}
}
}
}
Could it be by updating to the newer version of Unity?
Ok guys, i found the cause of the problem, now i'm searching for the solution. The touch problem is caused by rotating the screen orientation. In the game i'm rotating from the portrait to the landscape left. when i left the portrait, the touches are just ok and everything is going well. do you have any suggestions? :-)
Answer by Neklan · Jul 14, 2014 at 11:33 AM
I have resolved it. It seems that there is a bug in Unity version 4.5.1, when you rotate screen orientation manually in the code, the x coordinates are in negative numbers, and thats why the input events are not working. Bug was reported, but still in version 4.5.2 it is not resolved.
So solution for me and for others is to downgrade to the version 4.5.0 where this working well.
Hope that this post can save someone 50 hours of his life :-D
Your answer
Follow this Question
Related Questions
Unity iOS sdk question 1 Answer
iOS Shader - Emulator vs Device Inconsistency 0 Answers
WebCamTexture and VSync (iPhone 4) 3 Answers
Depth of Field Mobile 0 Answers
Making the switch to iPhone 1 Answer