//ON TOUCH DEVICES (MOBILE,TABLET) void update_touch() { touches = Input.touches; // stored for opti touchCount = Input.touchCount; // quantité de doigts a un instant T //first, check for new touch and assign touches to fingers for (int i = 0; i < touchCount; i++) { Touch touch = touches[i]; _finger = getFingerById(touches[i].fingerId); if (_finger == null) { _finger = getFirstAvailableFinger(); _finger.assign(touch.fingerId); } } //second, for each fingers apply state for (int i = 0; i < _fingers.Length; i++) { _finger = _fingers[i]; // never null Touch?touch = getSystemTouchById(_fingers[i].fingerId); if (touch != null) // active finger { _finger.update(touch.Value); } else if (_finger.isFingerNotCanceled()) { _finger.setEnded(); } } }
//ON PC void update_desktop() { bool mouseDown = Input.GetMouseButton(0); touchCount = mouseDown ? 1 : 0; //default finger _finger = _fingers[0]; if (mouseDown) { _finger.update(0, Input.mousePosition); } else if (_finger.isFingerNotCanceled()) { _finger.setEnded(); } }