Skip to content

Instantly share code, notes, and snippets.

@naojitaniguchi
Created October 21, 2015 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naojitaniguchi/a234317517cdb85d863e to your computer and use it in GitHub Desktop.
Save naojitaniguchi/a234317517cdb85d863e to your computer and use it in GitHub Desktop.
GUI button callback sample for Unity5
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ButtonCallback : MonoBehaviour {
// Use this for initialization
void Start () {
Button button = this.GetComponent<Button>();
button.onClick.AddListener(onClicked);
}
// Update is called once per frame
void Update () {
}
protected virtual void onClicked()
{
Debug.Log("onClicked");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment