private int beginTouch(Vector2 position) { var newID = (newTouchID++) % 10; var touch = new dfTouchTrackingInfo() { FingerID = newID, Phase = TouchPhase.Began, Position = position }; tracking.Add(touch); return(newID); }
public void Update() { if (Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButtonDown(1)) { if (altTouch != null) { altTouch.Phase = TouchPhase.Ended; } else { altTouch = new dfTouchTrackingInfo() { Phase = TouchPhase.Began, FingerID = 1, Position = Input.mousePosition }; } return; } else if (Input.GetKeyUp(KeyCode.LeftAlt)) { if (altTouch != null) { altTouch.Phase = TouchPhase.Ended; return; } } else if (altTouch != null) { if (altTouch.Phase == TouchPhase.Ended) { altTouch = null; } else if (altTouch.Phase == TouchPhase.Began || altTouch.Phase == TouchPhase.Moved) { altTouch.Phase = TouchPhase.Stationary; } } if (touch != null) { touch.IsActive = false; } if (touch != null && Input.GetKeyDown(KeyCode.Escape)) { touch.Phase = TouchPhase.Canceled; } else if (touch == null || touch.Phase != TouchPhase.Canceled) { if (Input.GetMouseButtonUp(0)) { if (touch != null) { touch.Phase = TouchPhase.Ended; } } else if (Input.GetMouseButtonDown(0)) { touch = new dfTouchTrackingInfo() { FingerID = 0, Phase = TouchPhase.Began, Position = Input.mousePosition }; } else if (touch != null && touch.Phase != TouchPhase.Ended) { var delta = (Vector2)Input.mousePosition - touch.Position; var moved = Vector2.Distance(Input.mousePosition, touch.Position) > float.Epsilon; touch.Position = Input.mousePosition; touch.Phase = moved ? TouchPhase.Moved : TouchPhase.Stationary; if (moved && altTouch != null && (MirrorAlt || ParallelAlt)) { if (MirrorAlt) { altTouch.Position -= delta; } else { altTouch.Position += delta; } altTouch.Phase = TouchPhase.Moved; } } } if (touch != null && !touch.IsActive) { touch = null; } }
private int beginTouch( Vector2 position ) { var newID = ( newTouchID++ ) % 10; var touch = new dfTouchTrackingInfo() { FingerID = newID, Phase = TouchPhase.Began, Position = position }; tracking.Add( touch ); return newID; }
public void Update() { if( Input.GetKey( KeyCode.LeftAlt ) && Input.GetMouseButtonDown( 1 ) ) { if( altTouch != null ) { altTouch.Phase = TouchPhase.Ended; } else { altTouch = new dfTouchTrackingInfo() { Phase = TouchPhase.Began, FingerID = 1, Position = Input.mousePosition }; } return; } else if( Input.GetKeyUp( KeyCode.LeftAlt ) ) { if( altTouch != null ) { altTouch.Phase = TouchPhase.Ended; return; } } else if( altTouch != null ) { if( altTouch.Phase == TouchPhase.Ended ) { altTouch = null; } else if( altTouch.Phase == TouchPhase.Began || altTouch.Phase == TouchPhase.Moved ) { altTouch.Phase = TouchPhase.Stationary; } } if( touch != null ) touch.IsActive = false; if( touch != null && Input.GetKeyDown( KeyCode.Escape ) ) { touch.Phase = TouchPhase.Canceled; } else if( touch == null || touch.Phase != TouchPhase.Canceled ) { if( Input.GetMouseButtonUp( 0 ) ) { if( touch != null ) { touch.Phase = TouchPhase.Ended; } } else if( Input.GetMouseButtonDown( 0 ) ) { touch = new dfTouchTrackingInfo() { FingerID = 0, Phase = TouchPhase.Began, Position = Input.mousePosition }; } else if( touch != null && touch.Phase != TouchPhase.Ended ) { var delta = (Vector2)Input.mousePosition - touch.Position; var moved = Vector2.Distance( Input.mousePosition, touch.Position ) > float.Epsilon; touch.Position = Input.mousePosition; touch.Phase = moved ? TouchPhase.Moved : TouchPhase.Stationary; if( moved && altTouch != null && ( MirrorAlt || ParallelAlt ) ) { if( MirrorAlt ) altTouch.Position -= delta; else altTouch.Position += delta; altTouch.Phase = TouchPhase.Moved; } } } if( touch != null && !touch.IsActive ) { touch = null; } }