- Home /
(4.6 UI) How to set up a window with x buttons, with a scroll bar?
Hi! I've been playing around with the 4.6 beta, but I've been having a hard time figuring things out... For part of my UI, I want to have a window that, depending on how many objects is in an array, makes buttons (one button per object in the array), and has a scroll bar if the list of buttons won't fit in the window.
How do you create a button in the script?
I'm assuming I can detect when to enable/disable the scroll bar by checking (button height * number of buttons), but how do I make it scroll down through the list of buttons?
What should I use for the window to hold it all, a Panel?
Any other tips/tricks/suggestions? Thanks for your help
You might want to watch the videos that Unity has put out regarding the use of the new UI system: https://www.youtube.com/watch?v=OD-p1e$$anonymous$$syrU&list=UUG08EqOAXJk_YXPDsAvReSg it is very in-depth and will likely answer your questions.
Answer by AyAMrau · Aug 30, 2014 at 02:10 AM
I think it's best to create a prefab for the button and then instantiate it, instead of trying to create it completely in script.
As for scrolling there is a Scroll Rect component, which you can combine with a Mask (so items are not visible outside the scroll area) and there is also a scroll bar object and component.
You can place you buttons under a parent with a vertical / horizontal layout group component and use layout element component on the button to control how they arrange and fit in the list.
Your answer
![](https://koobas.hobune.stream/wayback/20220613161851im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Move gameobject to button in new 4.6? 0 Answers
Unity 4.6 Beta Controller Menu Button Movement 0 Answers
Button onClick events will not be triggered 1 Answer
Embed GUI Skin in GUI Button 2 Answers
Unity 4.6 button movement problem 1 Answer