/// <summary> /// Handles the beginning of an Input. /// </summary> /// <param name="fingerID">ID of current Input.</param> /// <param name="position">position of current Input.</param> private void HandleInputBegan(int fingerID, Vector2 position) { bool hitUI = false; bool interacted = false; //Hit an UI Element (contains Canvas Renderer)? hitUI = CheckForUI(position); if (hitUI) { //Send TouchEnded Event with information that UI was hit if (OnTouchBegan != null) { OnTouchBegan(hitUI); } //Cancel Input Handle because UI was hit. return; } //Send Raycast, get GameObjects foreach (RaycastHit hit in CastWorldRay(position, Color.green)) { //Get ITouchable, if true trigger touch on gameObject ITouchable touchObject = hit.collider.gameObject.GetComponent <ITouchable>(); if (touchObject != null) { GetTouchFocus(fingerID).SetFocus(touchObject); touchObject.InputStart(); interacted = true; } //NOTE: Stop, because only one object shall be hit! if (interacted) { break; } } //Send OnTouch Event with information that no UI was hit. if (OnTouchBegan != null && !interacted) { OnTouchBegan(hitUI); } }