private void OnFingerSet(LeanFinger finger) { // Try and find the link for this finger var link = FindLink(finger); if (link != null) { // Has this finger been held for more than MinimumAge without moving more than MaximumMovement? var set = finger.Age >= MinimumAge && link.TotalScaledDelta.magnitude < MaximumMovement; link.TotalScaledDelta += finger.ScaledDelta; if (set == true && link.LastSet == false) { onFingerHeldDown.Invoke(finger); if (Instances[0] == this) { if (OnFingerHeldDown != null) { OnFingerHeldDown(finger); } } } if (set == true) { onFingerHeldSet.Invoke(finger); if (Instances[0] == this) { if (OnFingerHeldSet != null) { OnFingerHeldSet(finger); } } } if (set == false && link.LastSet == true) { onFingerHeldUp.Invoke(finger); if (Instances[0] == this) { if (OnFingerHeldUp != null) { OnFingerHeldUp(finger); } } } // Store last value link.LastSet = set; } }
private void OnFingerSet(LeanFinger finger) { var ray = finger.GetWorldPosition(1.0f); var hit = Physics2D.OverlapPoint(ray); //var hit = Physics2D.OverlapPoint(ray, LayerMask); // Try and find the link for this finger var link = FindLink(finger, false); if (hit != null) { if (link != null) { // Has this finger been held for more than MinimumAge without moving more than MaximumMovement? var set = finger.Age >= MinimumAge && link.TotalScaledDelta.magnitude < MaximumMovement; link.TotalScaledDelta += finger.ScaledDelta; if (set == true && link.LastSet == false) { if (OnHeldDown != null) { Debug.Log(hit.gameObject.name); ItemForHelpPanel.value = hit.gameObject; OnHeldDown.Invoke(finger); } } if (set == true) { if (OnHeldSet != null) { OnHeldSet.Invoke(finger); } } if (set == false && link.LastSet == true) { if (OnHeldUp != null) { ItemForHelpPanel.value = null; OnHeldUp.Invoke(finger); } } // Store last value link.LastSet = set; } } }
private void UpdateFinger(LeanFinger finger) { // Too old? if (finger.Age >= LeanTouch.CurrentTapThreshold) { return; } var delta = finger.ScreenPosition - finger.StartScreenPosition; // Invalid angle? if (CheckAngle == true) { var angle = Mathf.Atan2(delta.x, delta.y) * Mathf.Rad2Deg; var angleDelta = Mathf.DeltaAngle(angle, Angle); if (angleDelta < AngleThreshold * -0.5f || angleDelta >= AngleThreshold * 0.5f) { return; } } if (delta.magnitude * LeanTouch.ScalingFactor > LeanTouch.CurrentSwipeThreshold) { if (OnSwipe != null) { OnSwipe.Invoke(finger); } } }
public void OnFinger(LeanFinger finger) { if (finger.Age >= MinimumAge) { OnFingerHeld.Invoke(finger); } }
private void OnFingerUp(LeanFinger finger) { // Try and find the link for this finger var link = FindLink(finger); // Link exists? if (link != null) { if (link.Set == true) { onFingerHeldUp.Invoke(finger); if (Instances[0] == this) { if (OnFingerHeldUp != null) { OnFingerHeldUp(finger); } } } // Remove link from list links.Remove(link); } }
private void OnFingerUp(LeanFinger finger) { // Ignore this finger? if (IgnoreGuiFingers == true && finger.StartedOverGui == true) { return; } // Call event OnFingerSwipe.Invoke(finger); }
private void OnFingerUp(Finger finger) { if (dragging) { if (onDragEnd != null) { onDragEnd.Invoke(finger); } draggingFinger = null; dragging = false; } }
private void Update() { if (dragging) { if (draggingFinger != null) { if (onDrag != null) { onDrag.Invoke(draggingFinger); } } } }
private void UpdateFinger(LeanFinger finger) { // Too old? if (finger.Age >= LeanTouch.CurrentTapThreshold) { return; } if (OnTap != null) { OnTap.Invoke(finger); } }
private void OnFingerDown(Finger finger) { RaycastHit2D hit; if (OpenTouch.TouchManager.DidHitCollider2D(finger.guid, _collider, out hit)) { selectedFingerGUID = finger.guid; selected = true; if (onSelect != null) { onSelect.Invoke(finger); } } }
private void OnFingerDown(Finger finger) { RaycastHit2D hit; if (OpenTouch.TouchManager.DidHitCollider2D(finger.guid, _collider, out hit)) { draggingFinger = finger; if (onDragStart != null) { onDragStart.Invoke(finger); } dragging = true; } }
protected void CheckSwipe(LeanFinger finger, Vector2 delta) { if (CheckAngle == true) { var angle = Mathf.Atan2(delta.x, delta.y) * Mathf.Rad2Deg; if (Mathf.Abs(Mathf.DeltaAngle(angle, Angle)) >= AngleThreshold * 0.5f) { return; } } // Call event OnFingerSwipe.Invoke(finger); }
private void OnFingerUp(Finger finger) { if (selectedFingerGUID == finger.guid) { Debug.Log("selected GUID: " + selectedFingerGUID + " - new GUID: " + finger.guid); if (selected) { if (onDeSelect != null) { onDeSelect.Invoke(finger); } selected = false; } selectedFingerGUID = ""; } }
protected virtual void Update() { for (var i = 0; i < fingers.Count; i++) { var finger = fingers[i]; // Invoke OnSet if (OnSet != null) { OnSet.Invoke(finger); } // Skip other fingers? if (OnlyUseFirst == true) { break; } } }
private bool UpdateFinger(int index) { var finger = fingers[index]; // Remove fingers that are too old if (finger.Age >= LeanTouch.CurrentTapThreshold) { return(true); } for (var i = finger.Snapshots.Count - 1; i >= 0; i--) { var shapshot = finger.Snapshots[i]; var delta = finger.ScreenPosition - shapshot.ScreenPosition; // Invalid angle? if (CheckAngle == true) { var angle = Mathf.Atan2(delta.x, delta.y) * Mathf.Rad2Deg; var angleDelta = Mathf.DeltaAngle(angle, Angle); if (angleDelta < AngleThreshold * -0.5f || angleDelta >= AngleThreshold * 0.5f) { continue; } } if (delta.magnitude * LeanTouch.ScalingFactor > LeanTouch.CurrentSwipeThreshold) { if (OnFlick != null) { OnFlick.Invoke(finger); } return(true); } } return(false); }
private void OnFingerSet(LeanFinger finger) { // Try and find the link for this finger var link = FindLink(finger); if (link != null) { link.TotalScaledDelta += finger.ScaledDelta; link.Set = finger.Age >= MinimumAge && link.TotalScaledDelta.magnitude < MaximumMovement; if (link.Set == true && link.LastSet == false) { onFingerHeldDown.Invoke(finger); if (Instances[0] == this) { if (OnFingerHeldDown != null) { OnFingerHeldDown(finger); } } } if (link.Set == true) { onFingerHeldSet.Invoke(finger); if (Instances[0] == this) { if (OnFingerHeldSet != null) { OnFingerHeldSet(finger); } } } link.LastSet = link.Set; } }
private void OnFingerUp(LeanFinger finger) { // Ignore this finger? if (IgnoreGuiFingers == true && finger.StartedOverGui == true) { return; } if (CheckAngle == true) { var delta = finger.SwipeScreenDelta; var angle = Mathf.Atan2(delta.x, delta.y) * Mathf.Rad2Deg; if (Mathf.Abs(Mathf.DeltaAngle(angle, Angle)) >= AngleThreshold * 0.5f) { return; } } // Call event OnFingerSwipe.Invoke(finger); }
private void OnFingerSet(LeanFinger finger) { checkpos = finger.ScreenPosition; firsttouch = finger.GetWorldPosition(4.3f); if (finger.slidey != null) { Vector3 touchposfar = new Vector3(finger.ScreenPosition.x, finger.ScreenPosition.y, choose.farClipPlane); Vector3 touchposnear = new Vector3(finger.ScreenPosition.x, finger.ScreenPosition.y, choose.nearClipPlane); Vector3 touchposF = choose.ScreenToWorldPoint(touchposfar); Vector3 touchposN = choose.ScreenToWorldPoint(touchposnear); Debug.DrawRay(touchposN, touchposF - touchposN, Color.green, 2f); Ray TR = new Ray(touchposN, touchposF - touchposN); RaycastHit hit; string nameOfLayer = "TouchInput"; LayerMask layer = ~(1 << LayerMask.NameToLayer(nameOfLayer)); if (Physics.Raycast(TR.origin, TR.direction, out hit, Mathf.Infinity)) { //if (hit.collider.gameObject.tag == "placehere") { finger.slidey.transform.position = new Vector3(hit.point.x, line.gameObject.transform.position.y, line.gameObject.transform.position.z); //} //finger.slidey.transform.position=finger.GetWorldPosition(4.3f); } } if (CRunning) { } else if (CRunning == false) { //StartCoroutine(cheatdet(finger)); } // Try and find the link for this finger var link = FindLink(finger); if (link != null) { // Has this finger been held for more than MinimumAge without moving more than MaximumMovement? var set = finger.Age >= MinimumAge; link.TotalScaledDelta += finger.ScaledDelta; if (set == true && link.LastSet == false) { onFingerHeldDown.Invoke(finger); if (Instances [0] == this) { if (OnFingerHeldDown != null) { OnFingerHeldDown(finger); } //Posee = finger.GetStartWorldPosition(4.3f); //finger.spawnslide(SAA, finger.GetStartWorldPosition(4.3f)); } } if (set == true) { onFingerHeldSet.Invoke(finger); if (ischeating == false) { /*Vector3 touchposfar = new Vector3 (finger.ScreenPosition.x, finger.ScreenPosition.y, choose.farClipPlane); * Vector3 touchposnear = new Vector3 (finger.ScreenPosition.x, finger.ScreenPosition.y, choose.nearClipPlane); * Vector3 touchposF = choose.ScreenToWorldPoint (touchposfar); * Vector3 touchposN = choose.ScreenToWorldPoint (touchposnear); * Debug.DrawRay(touchposN, touchposF-touchposN, Color.green);*/ if (finger.slidey == null) { Vector3 touchposfarr = new Vector3(finger.ScreenPosition.x, finger.ScreenPosition.y, choose.farClipPlane); Vector3 touchposnearr = new Vector3(finger.ScreenPosition.x, finger.ScreenPosition.y, choose.nearClipPlane); Vector3 touchposFF = choose.ScreenToWorldPoint(touchposfarr); Vector3 touchposNN = choose.ScreenToWorldPoint(touchposnearr); Debug.DrawRay(touchposNN, touchposFF - touchposNN, Color.green, 2f); Ray ZR = new Ray(touchposNN, touchposFF - touchposNN); RaycastHit hit1; string nameOfLayer = "TouchInput"; LayerMask layer = ~(1 << LayerMask.NameToLayer(nameOfLayer)); if (Physics.Raycast(ZR.origin, ZR.direction, out hit1, Mathf.Infinity)) { //if (hit1.collider.gameObject.tag == "placehere") { finger.slidey = GameObject.Instantiate(SAA, new Vector3(hit1.point.x, line.gameObject.transform.position.y, line.gameObject.transform.position.z), Quaternion.identity); //} } } } else if (ischeating == true) { //Destroy(finger.slidey); //ischeating = false; } if (Instances [0] == this) { if (OnFingerHeldSet != null) { OnFingerHeldSet(finger); } } } if (set == false && link.LastSet == true) { onFingerHeldUp.Invoke(finger); if (Instances [0] == this) { if (OnFingerHeldUp != null) { OnFingerHeldUp(finger); } } } // Store last value link.LastSet = set; } }
protected bool CheckSwipe(LeanFinger finger, Vector2 swipeDelta) { // Invalid angle? if (CheckAngle == true) { var angle = Mathf.Atan2(swipeDelta.x, swipeDelta.y) * Mathf.Rad2Deg; var delta = Mathf.DeltaAngle(angle, Angle); if (delta < AngleThreshold * -0.5f || delta >= AngleThreshold * 0.5f) { return(false); } } // Clamp delta? switch (Clamp) { case ClampType.Normalize: { swipeDelta = swipeDelta.normalized; } break; case ClampType.Direction4: { if (swipeDelta.x < -Mathf.Abs(swipeDelta.y)) { swipeDelta = -Vector2.right; } if (swipeDelta.x > Mathf.Abs(swipeDelta.y)) { swipeDelta = Vector2.right; } if (swipeDelta.y < -Mathf.Abs(swipeDelta.x)) { swipeDelta = -Vector2.up; } if (swipeDelta.y > Mathf.Abs(swipeDelta.x)) { swipeDelta = Vector2.up; } } break; case ClampType.ScaledDelta: { swipeDelta *= LeanTouch.ScalingFactor; } break; } // Call event if (OnSwipe != null) { OnSwipe.Invoke(finger); } if (OnSwipeDelta != null) { OnSwipeDelta.Invoke(swipeDelta * Multiplier); } return(true); }
/* * protected virtual void Reset() * { * Start(); * } */ #endif protected bool CheckSwipe(LeanFinger finger, Vector2 swipeDelta) { //Debug.Log( "swipeDelta = " + swipeDelta ); //Check if the screen position hasn't moved much, if it hasn't, cancel the swipe if (Mathf.Abs(swipeDelta.x) < 5f && Mathf.Abs(swipeDelta.y) < 5f) { //Debug.Log( "Swipe Canceled... ScreenPosition = " + finger.ScreenPosition + ", LastScreenPosition = " + finger.LastScreenPosition ); return(false); } //Print out the snapshots of the finger movement that occured before the drag ended /* * if( finger.Snapshots != null && finger.Snapshots.Count > 0 ) * { * for( int i = 0; i < finger.Snapshots.Count; i++ ) * { * Debug.Log( "Snapshot[" + i + "] Age =" + finger.Snapshots[i].Age + ", pos = " + finger.Snapshots[i].ScreenPosition ); * } * } */ // Invalid angle? if (CheckAngle == true) { var angle = Mathf.Atan2(swipeDelta.x, swipeDelta.y) * Mathf.Rad2Deg; var delta = Mathf.DeltaAngle(angle, Angle); if (delta < AngleThreshold * -0.5f || delta >= AngleThreshold * 0.5f) { return(false); } } // Clamp delta? switch (Clamp) { case ClampType.Normalize: { swipeDelta = swipeDelta.normalized; } break; case ClampType.Direction4: { if (swipeDelta.x < -Mathf.Abs(swipeDelta.y)) { swipeDelta = -Vector2.right; } if (swipeDelta.x > Mathf.Abs(swipeDelta.y)) { swipeDelta = Vector2.right; } if (swipeDelta.y < -Mathf.Abs(swipeDelta.x)) { swipeDelta = -Vector2.up; } if (swipeDelta.y > Mathf.Abs(swipeDelta.x)) { swipeDelta = Vector2.up; } } break; case ClampType.ScaledDelta: { swipeDelta *= LeanTouch.ScalingFactor; } break; } // Call event if (OnSwipe != null) { OnSwipe.Invoke(finger); } if (OnSwipeDelta != null) { //Debug.Log( "LeanFingerSwipe.cs CheckSwipe() OnSwipeDelta.Invoke( " + ( swipeDelta * Multiplier ) + " )" ); OnSwipeDelta.Invoke(swipeDelta * Multiplier); } else { //Debug.Log( "LeanFingerSwipe.cs CheckSwipe() OnSwipDelta has no listeners" ); } return(true); }