button.onlick 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 onclick object
void Update () {
}
void OnMouseDown(){
// this object was clicked - do something
Destroy (this.gameObject);
}