what I want to do is to change the parameters of the buttons On click event(for example if the script(GETFromYTS.DisplayMovies) wants a string change that string). have not seen any good answers.
the "GetfromYTS.displaymovies" code:
public void DisplayMovies(string[] movieUrls)
{
//create text objects with the movie URLs
}
IDE is Jetbrains Rider
EDIT 1: new problem, how do I change the text of the button?
EDIT 2: the first problem solved. answer selected
According to the documentation , you can use button.onClick.AddListener(function);
.
The other functions (like removing one or more functions already associated with the button) are listed here .
Aside from daniel's answer, i'd like to add that in your onclick method you could thrown an unity event:https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html
This has some editor support, so in your editor you can call functions of other gameobjects.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.