GetButton and buttonName - what is the buttonName

I want to try out GetButton. Just so happens that I have a button, but I don't know the name, is it "Hole in One!"? If not, how is a name give to a button. Thanks!

GUI.Button (Rect (3,430,105,50), "Hole in One!")

The way you would use a Button is:

function OnGUI() {
    if (GUI.Button (Rect(3, 430, 105, 50), "Hole in One!")) {
        print("button pressed");

It doesn't really have a name, rather you create it and check if it was pressed - then do some code if it was pressed.

Read over the GUI Scripting Guide for more help on how to use the GUI.

Input.GetButton (which is what I believe you're referring to) is used for physical inputs (mice, keyboards, joypads). The "virtual" button described in the docs is the named button assigned to a physical input in the Input Manager. You "read" GUI buttons as Cyclops pointed out in this answer. It is possible, however, to name a GUI button using GUI.SetNextControlName if that's what you're really after, although this approach is primarily used to manage GUI focus and not to make some action happen when a GUI button is pressed.

hi guys. I just found that threat, by searching in google for the buttons names.

I think R Delano, asked you how he can access a button, that was created by script.

For example if we have: GUI.Button(Rect(2, 5, 20, 50), "Example Button");

What will happen if, few lines below i want to make that Button, inactive, so the player can’t click it. Can i access the Button’s enable property? This way i can put it to 0 or 1…

I found that there is a GUI.enabled class variable, but how i can make it to be exactly for the button, i want it to be? Cuz i might have 10 buttons… If the buttons have something like a system names, that we can use to reach their properties, etc…