public void OnEndDrag(PointerEventData eventData) { if (IsBeingDrag) { // Set input magnify ability on again if (!mMatchInput.CanMagnify) { mMatchInput.CanMagnify = true; } // Return the card old sorting order gameObject.transform.Find("Sprites").GetComponent <Canvas> ().sortingOrder = SortingOrder; gameObject.transform.Find("Texts").GetComponent <Canvas> ().sortingOrder = SortingOrder + 1; SortingOrder = -10; Ray tRay; RaycastHit tHit; tRay = Camera.main.ScreenPointToRay(Input.mousePosition); // Check gameobject the ray hit if (Physics.Raycast(tRay, out tHit, 10000)) { // If the card is dropped in the correct target if (tHit.collider.transform.tag == mCardController.Target) { if (IsCursorTarget) { mMatchController.ChangeCursorToDefault(); mMatchController.TargetEnemy = tHit.collider.gameObject; } // Play the card through MatchController; StartCoroutine(mMatchController.PlayCard(gameObject)); } else { // Reset card position back to the hand and tell match controller no card is being consider mMatchController.AlignHand(); mMatchController.CardBeingPlay = null; } } } }