using UnityEngine; using System.Collections; /// /// Base class for multi-finger gestures that require individual access to each finger position (as opposed to averaged position) /// public abstract class MultiFingerGestureRecognizer : GestureRecognizer { Vector2[] pos; Vector2[] startPos; /// /// Initial finger positions (one per active finger/touch) /// protected Vector2[] StartPosition { get { return startPos; } set { startPos = value; } } /// /// Current finger positions (one per active finger/touch) /// protected Vector2[] Position { get { return pos; } set { pos = value; } } protected override void Start() { base.Start(); OnFingerCountChanged( GetRequiredFingerCount() ); } protected void OnFingerCountChanged( int fingerCount ) { StartPosition = new Vector2[fingerCount]; Position = new Vector2[fingerCount]; } /// /// Number of touches used by the gesture /// public int RequiredFingerCount { get { return GetRequiredFingerCount(); } } /// /// Get the position of the finger at the given index /// /// index of the finger to retrieve public Vector2 GetPosition( int index ) { return pos[index]; } /// /// Get the initial position of the finger at the given index /// /// index of the finger to retrieve public Vector2 GetStartPosition( int index ) { return startPos[index]; } }