Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity button press onclick click add C#

using UnityEngine;
using UnityEngine.UI;

public class Example : MonoBehaviour
{
	[SerializeField]
    private Button button;
    
    void Start()
    {
    	button.onClick.AddListener(RunThisTask);
    }
    
    void RunThisTask(){
    	//do something
    }
}
 
PREVIOUS NEXT
Tagged: #unity #button #press #onclick #click #add
ADD COMMENT
Topic
Name
2+3 =