/// <summary> /// Checks if the touchevent is exiting and releases this object from being grabbed /// </summary> /// <param name="touchInfo"></param> /// <param name="eventType"></param> private void CheckForLetGo(TouchInfo touchInfo, ETouchEventType eventType) { if (eventType == ETouchEventType.EXIT && m_touchInfo != null && touchInfo.FingerId == m_touchInfo.FingerId) { OnTouchEnd(touchInfo); canGrab = false; StartCoroutine(SetCanGrabAfterDelay()); } }
/// <summary> /// Checks to see if a touchevent is a valid touch event to grab this object. /// </summary> /// <param name="touchInfo"></param> /// <param name="eventType"></param> private void CheckForGrab(TouchInfo touchInfo, ETouchEventType eventType) { if (canGrab && eventType != ETouchEventType.EXIT && m_touchInfo == null && touchInfo.m_owners == 0) { touchInfo.m_owners++; m_touchInfo = touchInfo; m_touchInfo.ListenForMove(OnTouchMove); m_touchInfo.ListenForEnd(OnTouchEnd); Grab(); } }
private void CheckForTouch(TouchInfo touch, ETouchEventType eventType) { if (eventType != ETouchEventType.EXIT && m_touchInfo == null) { Debug.Log("Touch Start"); m_touchInfo = touch; m_touchInfo.ListenForMove(OnMove); m_touchInfo.ListenForEnd(OnEnd); transform.position = m_touchInfo.WorldPosition(); m_spriteRenderer.enabled = true; } else if (eventType == ETouchEventType.EXIT && m_touchInfo.FingerId == touch.FingerId) { Debug.Log("Touch Exit"); OnEnd(touch); } }