/ Published in: C#

detect touch input on unity 2D android device
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
if(Input.touchCount == 1 && Input.GetTouch(0).phase== TouchPhase.Began) { Vector3 pos = Camera.main.ScreenToWorldPoint (Input.GetTouch(0).position); RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.zero); if (hit != null)// && hit.collider != null) { // Debug.Log ("I'm hitting "+hit.collider.name); status.text = "hit on"+hit.transform.gameObject.name; } }
Comments
