Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

using UnityEngine;

using UnityEngine.UI;

public class ButtonAction : MonoBehaviour


{
// Reference to the button component
private Button button;

private void Start()


{
// Get the Button component attached to this GameObject
button = GetComponent<Button>();

// Add a listener for the button click event


button.onClick.AddListener(TaskOnClick);
}

private void TaskOnClick()


{
// This method will be called when the button is clicked
Debug.Log("Button clicked! Perform your action here.");
}
}

You might also like