click event unity code example
Example 1: onmouseclick unity
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;public class ExampleClass : MonoBehaviour
{
void OnMouseDown()
{
// Destroy the gameObject after clicking on it
Destroy(gameObject);
}
}
Example 2: unity click object
void OnMouseDown()
{
// this object was clicked - do something
Destroy (this.gameObject);
}