Trouble with On Click ( ).

Everything I see about assigning a function to a button involves using the On Click thing. When I see other people do it, they click “No function” and see quite a few different options to go from there. The thing is, even though I referenced my chosen script in the On Click event, all that shows up is MonoScript. And, under that, “string name”. According to all other resources I’ve checked, there should be more. And, yes, my function is public. Also, I’m using Unity 2019.3.7f1.

Hi @JoeAndHalf and welcome,

Did you add an OnClick() event, then drag an object from the scene to that slot in the box? Then check that right side drop down menu. There you should find your script under a section with the name of your script (like UIThing, if you named it UIThing.) And under that section you should see your method somewhere in the list, among the in-built paramaters/methods etc. of the base class that are shown.

Also, if you have a method with more than one parameter, it will not show up in the menu.

For example, this will show up (a method with one string parameter):

public void MyOnClickMethod(string myString) { }

But this will not:

public void MyOnClickMethod(string myString, int myInt) { }

I dragged my script into the slot, and my function takes no parameters. It’s a simple thing where pressing the button will call the function, Quit(), which results in the closing of the application. Under the drop-down menu, the name of my script is not there. And, of course, neither is the function I want called.