public void TouchUpdate() { FingerInput fingerinput; if (Input.touchCount > 0) { for (int i = 0; i < Input.touchCount; i++) { if (fingerInputDic.TryGetValue(Input.touches[i].fingerId, out fingerinput) == false) { if (Input.touches[i].phase == TouchPhase.Began) { fingerinput = new FingerInput(Input.touches[i].fingerId); fingerInputDic.Add(Input.touches[i].fingerId, fingerinput); } } rayHitLayer = Define.LAYERMASK_ALL_PICKLAYER; fingerinput.SetCurrentPoint(Input.touches[i].phase, Input.touches[i].position); switch (Input.touches[i].phase) { case TouchPhase.Moved: { fingerinput.pressingAcumTime += Time.deltaTime; float dragDelta = Vector2.Distance(fingerinput.beginPoint, fingerinput.currentPoint); fingerinput.isDragging = (dragDelta > DRAG_THRESHOLD) ? true : false; } break; case TouchPhase.Stationary: { fingerinput.pressingAcumTime += Time.deltaTime; fingerinput.isPressed = true; } break; case TouchPhase.Ended: case TouchPhase.Canceled: { fingerinput.isPressed = false; fingerinput.pressingAcumTime = 0.0f; fingerinput.isDragging = false; } break; } fingerinput.prevTouchPhase = fingerinput.currentTouchPhase; } } else { if (Input.GetMouseButtonDown((int)MouseButton.Left)) { rayHitLayer = Define.LAYERMASK_ALL_PICKLAYER; if (fingerInputDic.TryGetValue((int)MouseButton.Left, out fingerinput) == false) { fingerinput = new FingerInput((int)MouseButton.Left); fingerinput.SetCurrentPoint(TouchPhase.Began, Input.mousePosition); fingerInputDic.Add((int)MouseButton.Left, fingerinput); } } else if (Input.GetMouseButtonUp((int)MouseButton.Left)) { if (fingerInputDic.TryGetValue((int)MouseButton.Left, out fingerinput) == true) { fingerinput.SetCurrentPoint(TouchPhase.Ended, Input.mousePosition); fingerinput.isDragging = false; fingerinput.isPressed = false; fingerinput.pressingAcumTime = 0.0f; } } else if (Input.GetMouseButton((int)MouseButton.Left)) { if (fingerInputDic.TryGetValue((int)MouseButton.Left, out fingerinput) == true) { fingerinput.SetCurrentPoint(TouchPhase.Moved, Input.mousePosition); float dragDelta = Vector2.Distance(fingerinput.prevPoint, fingerinput.currentPoint); fingerinput.isDragging = (dragDelta > DRAG_THRESHOLD) ? true : false; fingerinput.isPressed = true; fingerinput.pressingAcumTime += Time.deltaTime; } } else { if (fingerInputDic.Count > 0) { fingerInputDic.Clear(); } } } }