Unity:How to Get Simple Touch Input

How to get simple touch input from touch devices:

In Your Update method write the code

foreach (Touch touch in Input.touches)

{

Vector3 pos = camera.ScreenToWorldPoint(touch.position);

RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.zero);

if (hit != null && hit.collider != null)

{

Debug.Log("I'm hitting Android" + hit.collider.name);

}

}

Comments