Objects act like buttons

Hi,

I want to make a object a button so when it’s pressed it will run a script. How do I do this?

Thanks

For pc you add a script which has:

function OnMouseDown () {
    //Do your stuff
}

For mobile devices you will have to use raycast:

var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
    if(hit.gameObject.Tag == "myCube") 
        //Do your stuff
}