- Home /
My Function is not showing up in the OnClick Menu
Hey guys, so I am trying to create a button that runs a function in my script. I dragged the object into the OnClick, and the script shows up, but not the function I put in there, only base GameObject functions. I looked this up, and the only response is that you can only use functions that return void, are public, and only take 0 or 1 parameters, but my function satisfies all those conditions, and it still doesn't show up.
EDIT: Well, people asked to see the function. I didn't post it because I just described the whole thing...
public void Advance()
{
stage++;
}
I know there's not much to it, but I will add more, this was just to make sure that the button worked...
EDIT 2: What...The function shows up now, but I didn't change anything..and don't say it was a problem with me saving the script, as I had made sure to save he script, save the scene, and even restarted unity, with no results. And I started up Unity today...and it was there. No clue, maybe it need 24 hours to process...
"...take 0 or 1 parameters" and must be an int, bool, float, string or unity object.
Well, it takes in zero parameters, so I think I'm ok on that front.
What do you mean when you say that "only base GameObject functions" show up? Perhaps you could show us a screenshot of the drop-down you get there. There ought to be a sub-list for GameObject as well as one for Transform, plus one for each of the components you've added to the GameObject.
Another possibility I guess is that you've mistakenly written "GameObject" ins$$anonymous$$d of "$$anonymous$$onoBehaviour"? (ie your own script does show up but the only functions in its sublist are ones it gets from $$anonymous$$onoBehaviour).
And it is kind of strange to ask this question without showing us the code for the function.
Answer by L_Artista · Jan 07, 2016 at 07:28 AM
Make should it is public and doesn't have more than 1 parameter!
He already wrote in the question, that these conditions are satisfied.
Answer by Death_Nova · Aug 12, 2018 at 01:32 AM
Not applicable to your script, but something quirky I found. My button would not accept an enum value as the argument. Using int value and (enum)value now, but the script would not show up until the argument was of a basic type.
This is as expected, see saschandroid's comment to the original question.