Skip to content

Instantly share code, notes, and snippets.

@dakom
Created November 12, 2014 10:13
Show Gist options
  • Save dakom/aa351d0e9af77046cc18 to your computer and use it in GitHub Desktop.
Save dakom/aa351d0e9af77046cc18 to your computer and use it in GitHub Desktop.
Test Unity touch info even if not hitting current collider
//http://answers.unity3d.com/questions/425478/onmousedown-not-firing.html
void Update () {
if (Input.GetMouseButtonDown (0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Debug.Log ("Name = " + hit.collider.name); Debug.Log ("Tag = " + hit.collider.tag); Debug.Log ("Hit Point = " + hit.point); Debug.Log ("Object position = " + hit.collider.gameObject.transform.position); Debug.Log ("--------------"); } }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment