Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
You hang a button in the Canvas , then either subscribe the required method to the click event in the inspector, or do it through a script:
using UnityEngine;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
public Button button;
private void Start()
{
button.onClick.AddListener(OnClick);
}
private void OnClick()
{
Debug.Log("Click");
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question