Attaching script to Onclick

Hi all,

I have a script which includes Onclick functions for two buttons. The script handles all menu functionality so there are also some public variables which are not the two buttons, but panels.

If I drag it from assets to Onclick for the buttons, it appears but none of the functions appear. All I get in the dropdown is “No functions” and “Monobehavior”.

If I add the script as a component and then drag it in the inspector to OnClick, it sees the script and the functions are present in the dropdown and I can set them as the OnClick function. The hassle then is the script because it is now a component of the button runs the other functions (such as Start) in the script for each button of which the script is a component.

Any thoughts?

Solved it. Add the script to a game object and then attached the object to the OnClick and it worked. Weird!