The document contains a C# script that defines a ButtonAction class to handle click events for a Unity UI button. The class gets the button component and adds a listener to call TaskOnClick on click, which logs a message.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
17 views3 pages
Skripta 1
The document contains a C# script that defines a ButtonAction class to handle click events for a Unity UI button. The class gets the button component and adds a listener to call TaskOnClick on click, which logs a message.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3
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."); } }
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."); } }
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."); } } 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."); } }
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."); } }