Posted By

vishnuajit on 03/13/15


Tagged

Unity androidtouch


Versions (?)

detect touch input on unity 2D android device


 / Published in: C#
 

detect touch input on unity 2D android device

  1. if(Input.touchCount == 1 && Input.GetTouch(0).phase== TouchPhase.Began)
  2. {
  3. Vector3 pos = Camera.main.ScreenToWorldPoint (Input.GetTouch(0).position);
  4. RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.zero);
  5. if (hit != null)// && hit.collider != null)
  6. {
  7. // Debug.Log ("I'm hitting "+hit.collider.name);
  8. status.text = "hit on"+hit.transform.gameObject.name;
  9. }
  10.  
  11. }

Report this snippet  

You need to login to post a comment.