I’ve made public functions in my scripts and attached the objects to the OnClick but I can’t select or see any functions from the script.

Try this:

  • create an empty object in your scene
  • Attach your script to it (Drag and drop your script into that object inspector to create a scrip component)

in button

  • Drag and drop the object created above in the Object field on the OnClick event (and not the script itself from your Project tree)

That should work.

I had the same issue - here is what worked for me.

I was dragging the script directly to the button, which doesn’t work.
I needed to drag the object which contains the script onto the button!

After i did that, the functions showed up!

see Diego’s response: http://answers.unity3d.com/questions/972191/why-wont-my-function-show-up-in-the-onclick-area-o.html

I have your answer! You need to make sure that the function that your trying to put on the button is a public function. If that doesnt work right away just re reference you object containing the script :slight_smile:

I had the same problem, where I had created a new method that wouldn’t show up in the OnClick for that script. I discovered that if I have any compile errors in any linked scripts, the inspector won’t update.

I just found out that you also can’t use functions with “yield WaitForSeconds();” in it.

Make sure your method is void, public and has no more then 1 parameter.

examples:

public void Methodname()
{

}

public void Methodname(string param)
{

}

public void Methodname(bool param)
{

}

Also make sure your class and/or method is not static. Attach the script to a GameObject and drag the gameobject onto the onClick event in the inspector. Select the method you wish to execute on the click.

I’ve just come across this issue, and what fixed it for me was having only ONE method input parameter.

Credits to @CorruptedTNC : My function doesn’t appears in the OnClick button script

I had the same problem but I found out that I had a simple mistake in the code before writing the function. After I correct the mistake the functions were detected.

Did not work for me, turns out it can only take ONE STRING as parameter… how stupid