Arte

How to align GUI.Button horizontally

Recommended Posts

Hi and a warm welcome to the forum. Hope this PG helps https://www.babylonjs-playground.com/#4P8PJY#2 

It is worth checking out what happens when you change LEFT in line

panel.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;

to CENTER and RIGHT. Also add the line

panel.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER;

just afterwards and then change CENTER to TOP and then BOTTOM.

Note also that the use of padding to get spaces between the buttons decreases the usable area of the button so I have increased the size of the button to match ie usable width 80, padding left 5, padding right 5 and so button width = usable width + padding left + padding right = 80 + 5 + 5 = 90.  OK I made it 100 to give more space around Right-Top.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.