Creating a Working GUI, Buttons

I am working on creating a GUI screen with several buttons which call functions. I am working off of this tutorial http://www.youtube.com/watch?v=NsZ_XBCPR2s&list=PLB4DA4F8BDC3B82EE&index=31 but I am not sure if it is the best methode or not. I understand that you can manually put in the buttons, but I am unsure of how many buttons I will be having in the end, so it is nice to be able to edit the list as fast as I need. Anyway, I want to have a lot of buttons (by the end maybe around 20) placed on a GUI window, I would also like to have a scroll bar on the side since the buttons will be fairly large.

My largest problem is how do I reference a function with each button press? So if I press button #3 I can call a particular function, but if I press #4 I can call a different function. I have a lot of questions, but I think this will be the best place for me to start is figuring out how to at least make the buttons work, I can work on visuals after.

I would also like to make the camera stop moving when I open the GUI, having a little issue figuring that one out too :stuck_out_tongue:

Thanks for any help you may be able to give!

Alright so I have figured out a good part of the camera script at least. Although it seems to only work for 1 axis (x), not both.

public var cameraScript : MouseLook;

cameraScript.enabled = false;

this seems to do the trick, but again only for the x axis

As for my GUI problem, I still can’t quite figure it out. Not sure the Unity help section is working well enough for me either, but I will keep trying!

In which language are you programming ?
C# example:

void OnGUI()
{
    if (GUILayout.Button("Button 1"))
    {
        Test();
    }
}

void Test()
{
    Debug.Log("test method called");
}