void CheckForMultiTouch() { if (Input.touchCount == 2 && Input.GetTouch(0).phase == TouchPhase.Moved && Input.GetTouch(1).phase == TouchPhase.Moved) { curDist = Input.GetTouch(0).position - Input.GetTouch(1).position; prevDist = ((Input.GetTouch(0).position - Input.GetTouch(0).deltaPosition) - (Input.GetTouch(1).position - Input.GetTouch(1).deltaPosition)); float touchDelta = curDist.magnitude - prevDist.magnitude; if (touchDelta > 0) { if (OnZoomOut != null) { OnZoomOut.Invoke(touchDelta); } } else if (touchDelta < 0) { if (OnZoomIn != null) { OnZoomIn.Invoke(touchDelta); } } } #if UNITY_EDITOR else if (Input.GetAxis("Mouse ScrollWheel") < 0) { if (OnZoomOut != null) { OnZoomOut.Invoke(Input.GetAxis("Mouse ScrollWheel")); } } else if (Input.GetAxis("Mouse ScrollWheel") > 0) { if (OnZoomIn != null) { OnZoomIn.Invoke(Input.GetAxis("Mouse ScrollWheel")); } } #endif else if (Input.touchCount == 2 && (Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.GetTouch(1).phase == TouchPhase.Ended || Input.GetTouch(1).phase == TouchPhase.Canceled)) { if (OnGestureEnd != null) { OnGestureEnd.Invoke(); } } }
public void ClearAllEventListeners() { OnZoomIn.RemoveAllListeners(); OnZoomOut.RemoveAllListeners(); OnGestureEnd.RemoveAllListeners(); }