public void Update(UpdateArgs e) { _touches.Clear(); for (var i = 0; i < Input.touchCount; i++) { var touch = new TouchInfo(Input.GetTouch(i), e.time); touch.CalRay(CreateArgs.Camera, new Plane(Vector3.forward, Vector3.zero)); if (!_touches.ContainsKey(touch.id)) { _touches.Add(touch.id, touch); } else { _touches[touch.id] = touch; } UpdateTouch(touch); } foreach (var contaier in _containers) { if (contaier.Key == MouseTouchId) { continue; } if (!_touches.ContainsKey(contaier.Key)) { _endList.Add(contaier.Value); } } UpdateMouse(e); ExecuteStartList(e); ExecuteUpdateList(e); ExecuteEndList(e); }
void UpdateMouse(UpdateArgs e) { var lbState = Input.GetMouseButton(0); var id = MouseTouchId; var touch = new TouchInfo(MouseTouchId, TouchPhase.Began, Input.mousePosition, e.time); touch.CalRay(CreateArgs.Camera, new Plane(Vector3.forward, Vector3.zero)); TouchContainer container = null; if (lbState) { touch.id = id; if (_containers.ContainsKey(id)) { container = _containers[id]; _updateList.Add(container); touch.phase = TouchPhase.Moved; } else { container = _containersPool.Obtain(CreateTouchContainer); container.Id = id; _containers.Add(id, container); _startList.Add(container); touch.phase = TouchPhase.Began; } container.Touch = touch; } else { if (_containers.ContainsKey(id)) { container = _containers[id]; _endList.Add(container); touch.phase = TouchPhase.Ended; container.Touch = touch; } } }