click on object unity code example
Example 1: gameobject on click unity
private void OnMouseOver() {
Debug.Log("Hovering over GameObject");
}
Example 2: unity click object
void OnMouseDown()
{
// this object was clicked - do something
Destroy (this.gameObject);
}
Example 3: detect object click unity
void Update () { } void OnMouseDown(){ // this object was clicked - do something Destroy (this.gameObject); }