Creating a list of scrollable buttons in Unity from C # scripting


Hi guys I'm totally new to Unity3D. I'm trying to create a scrollable button list where users can scroll through a list of buttons inside a panel. So I have a OnGUI function and inside of it I created some buttons that are of the same width and height. Their Y-axis position is separated by about 55 units each. This is all done in Unity's C# script. I attached the script to a panel and that panel is also attached with a vertical scrollbar. I added the Mask component in the panel where I unchecked the Show Mask Graphic. But when I click play, the buttons do not show up at all. Is it possible to create a scrollbar inside the script and attach to the button list? Thanks

Ok I would highly advise you use the new Unity UI system instead of using Immediate Mode GUI (OnGui functions). You can still control things programatically with ease but it is much easier with a canvas to work with.

You mention using panels and masks but they don't mix with the OnGui setup, that is the legacy UI system and should only be used for Unity editor plug ins.

That said there are great learning resources which cover exactly what you need in these three tutorials on the Unity site:

And if you have not got any experience using the newer system the main tutorial page is here.

I hope that helps.