void Update() { if (touch != null && touch.phase == MultiplatformTouchPhase.Ended) { touch = null; } DetectTouches(); DetectSwipe(); }
void DetectTouches() { if (Input.GetMouseButtonDown(0)) { touch = new MultiplatformTouch(Input.mousePosition); } else if (Input.GetMouseButton(0)) { if (touch != null) { touch.ChangePosition(Input.mousePosition); } else { Debug.LogWarning("Why touch == null???"); } } else if (Input.GetMouseButtonUp(0)) { if (touch != null) { touch.EndTouch(); } else { Debug.LogWarning("Why touch == null???"); } } // Touch[] mobileTouches = Input.touches; // touches = new List<MultiplatformTouch>(); // for (int i = 0; i < mobileTouches.Length; i++) // { // } //#if UNITY_IOS || UNITY_ANDROID // Touch[] mobileTouches = Input.touches; //#else // if (Input.GetMouseButtonDown(0)) // { // } // else if (Input.GetMouseButton(0)) // { // } // else if (Input.GetMouseButtonUp(0)) // { // } //#endif }