How to add touch input for mobile devices using unity?

You can use Input.GetMouseButtonDown(0)

example :

    if (Input.GetMouseButtonDown(0))
    {
         //code
    }

You can go to this link for more detail

http://docs.unity3d.com/Documentation/ScriptReference/Input.GetMouseButtonDown.html


And you can also use Input.GetTouch

You can go to this link for more detail

http://docs.unity3d.com/Documentation/ScriptReference/Input.GetTouch.html

if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android)
{
foreach (Touch touch in Input.touches)
{
if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) {
if (_joystickIndex==touch.fingerId){
_joystickIndex=-1;
_enaReset=true;
}
}

if(_joystickIndex==touch.fingerId){
OnTouchDown(touch.position);
}
if (touch.phase == TouchPhase.Began) {
if (((Vector2)touch.position - _joystickCenter).sqrMagnitude < Mathf.Pow((zoneRadius+touchSizeCoef/2),2)){
_joystickIndex = touch.fingerId;
}
}
}

UpdateJoystick();
if(_enaReset){
ResetJoystick();
}
}