Hello all.
I’m trying to create programmatically an horrizontal centered list of UI buttons like in this img:
how can i do that?
Hello all.
I’m trying to create programmatically an horrizontal centered list of UI buttons like in this img:
how can i do that?
Are you using uGUI (Canvas, Unity UI, RectTransform…) or UIElements (VisualElement, USS, UXML, …)?
nGUI (:
Ah, then this is not the best sub forum. Moving thread to uGUI forum.
A Horizontal Layout Group or Grid Layout Group can be used to automatically spread things out. The “child alignment” property can be used to make the group as a whole be horizontally centered (or whatever).
If you’re already creating the content programmatically, you might also consider setting the position of each object explicitly in your script as they get created. This won’t cause them to update automatically if circumstances change, but it gives you more precise control and may be more efficient.