Is there a way, or script that can help distinguish finger gesture on iOS
For exemple, how to make the diffrence between a simple tap, a swipe, a pinch... ?
a kind of equivalent to the "UIGestureRecognizer class" for Ios
(http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/cl/UIGestureRecognizer)
system
April 8, 2011, 1:27pm
2
system
May 11, 2012, 12:26pm
5
I use the following code. It works but i guess there are better ways to do it.
float pinchLength = 0f;
void Update(){
if(Input.touchCount == 2 && Input.GetTouch(1).phase == TouchPhase.Began){
pinchLength = Vector2.Distance(Input.GetTouch(0).position, Input.GetTouch(1).position);
}
if(Input.touchCount == 2 && (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(1).phase == TouchPhase.Moved)){
float deltaLength = Vector2.Distance(Input.GetTouch(0).position, Input.GetTouch(1).position);
Game.cameraManager.ZoomBy(Mathf.Clamp(1f/pinchLength*(deltaLength),-1.5f,1.5f)); // ZoomBy(float Zoomfactor between -1.5x and +1.5x), eg orthographicSize
pinchLength = Vector2.Distance(Input.GetTouch(0).position, Input.GetTouch(1).position);
}
}
DaveA
April 8, 2011, 4:05pm
3
There's a swipe utility in the Asset Store. I've not tried it myself yet, but it's nicely priced.
system
July 9, 2011, 12:21am
4
You might be interested in checking out the FingerGestures scripting package from the Asset store. This is pretty much what you’re after. You can get more information in the forum thread at http://forum.unity3d.com/threads/95983-FingerGestures-Robust-input-gestures-at-your-fingertips !