Unity Tasty Tidbits

Move an object like a button press.

[script]
var tmp = transform.position;
tmp.x += .08f;
transform.position = tmp;
[/script]

Respond to a button click

On a an object with box colllider.
“Is Trigger” is Checked.
Add the following script…
[script]
void OnMouseDown()
{
var tmp = transform.position;
if (!clicked)
{
clicked = true;
tmp.x -= .08f;
}
else
{
clicked = false;
tmp.x += .08f;
}
transform.position = tmp;
}
[/script]