- Home /
New UI listView
Hello.
I have script that downloads JSON from server then parses it to my classes. Now I want to create list of buttons that will scroll down.
I have created panel with Scroll rect component. Added Mask. Created new panel and made it child of my scroll rect panel and it will be my content. Anchors will strech to its parent.
I have created somewhere else (in canvas) button with images and texts. Anchors set to middle of canvas.
I have arrayList of my classes and I use foreach function to instantiate this button and set it as child to my content panel.
Question. how do I need to calculate offsets, in order to place it as list inside my panel?
Answer by Kiwasi · Nov 04, 2014 at 06:39 AM
Since you are using the new UI you can just use the layout components. There is a vertical layout group and a layout element that will do the job.
I happen to have a video tutorial here that uses the layout components on a dropdown menu. But the components are reasonably easy to figure out.
I have added VerticalLayout component to my Contents panel. Instanciated all my prototypes and made them child of my contents panel. Problem is that heights of children are very small and I can barely see its contents.
You need to add a layout element to each child. Set the $$anonymous$$imum height to whatever you like.
But how I can make my prototypes proprely scaled. It does not look like prototype, it looks like it was zoomed in.
I want it look exactly like my prototype. I made preffered width and height. However it zooms my prototypes like that.
Set the flexible height and width on the layout element to zero