change what button do when clicking after unity code example

Example 1: unity change button onclick in script

public void Test(){ Debug.Log ("testttt"); }

Example 2: unity change button onclick in script

using UnityEngine; using UnityEngine.UI; using System.Collections;  public class ClickExample : MonoBehaviour {     public Button CustomButton; //drag-n-drop the button in the CustomButton field      void Awake()     {         CustomButton.onClick.AddListener(CustomButton_onClick); //subscribe to the onClick event     }      //Handle the onClick event     void CustomButton_onClick()     {         Debug.Log("testtttt");     } }

Tags:

Misc Example