void UpdateInternal() { bool shouldContinue = true; if (pendingData.Count == 0) { bool began = false; foreach (var item in touches) { var touch = item.Value; if (touch.phase == TouchPhase.Began) { touch.Move(touch.position.x, touch.position.y); began = true; } } if (began) { return; } } foreach (var d in pendingData) { if (!shouldContinue) { left.Add(d); continue; } switch (d.type) { case Data.Type.MouseDown: { mouseDown[d.index] = true; firstMouseDown[d.index] = true; mousePosition.x = d.x; mousePosition.y = d.y; break; } case Data.Type.MouseUp: { mouseDown[d.index] = false; firstMouseUp[d.index] = true; mousePosition.x = d.x; mousePosition.y = d.y; break; } case Data.Type.MouseMove: { mousePosition.x = d.x; mousePosition.y = d.y; break; } case Data.Type.TouchStart: { int index = mapFingerID(d.index); Touch touch = new Touch(); touch.fingerId = 0; touch.tapCount = 1; touch.deltaTime = 0; touch.Start(d.x, d.y); touch.fingerId = index; touches[index] = touch; shouldContinue = false; break; } case Data.Type.TouchMove: { int index = mapFingerID(d.index); touches[index].Move(d.x, d.y); break; } case Data.Type.TouchCancel: { int index = mapFingerID(d.index); touches[index].Cancel(d.x, d.y); unmapFingerID(d.index); shouldContinue = false; break; } case Data.Type.TouchEnd: { int index = mapFingerID(d.index); touches[index].End(d.x, d.y); unmapFingerID(d.index); shouldContinue = false; break; } } } if (left.Count > 0) { var t = left; left = pendingData; left.Clear(); pendingData = t; } else { pendingData.Clear(); } fingerIds = new List<int>(touches.Keys); foreach (var id in fingerIds) { var touch = touches[id]; if ((touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) && touch.time < Time.time) { touches.Remove(id); } } if (fingerIds.Count != touches.Count) { fingerIds = new List<int>(touches.Keys); } // Console.WriteLine("touchCount"+touchCount); }