button.onClick Question

When a button is clicked, it can be set to call a public function of one of the components of an object given to it. This public function can also have one parameter, like an int, where when that function is selected in the inspector under the Button script, you must enter a parameter.

Is it possible to change that parameter or the function selected through a script? I know there is a button.onClick aspect of buttons when scripting, but how would I change the function that is called when a button is clicked, and, more importantly, how would I change the argument passed to that function when the button is clicked? By default, that argument passed is 0 for and int (which is what I would need to pass to the function I am calling).

Sorry about the confusing description, but it is the best I can do. I hope you can help :slight_smile:

You generally don’t set a variable in the inspector. I would make a duplicate public function and have it call the other with the assigning variable.

This is really dumb for doing grided data entry buttons. What you can do is simply create a script that will create the grided button and use the OnMouseDown method for the button object. This will achieve the same result.

Alright thanks :slight_smile: