Jump to content

[:Debugged:] moveToVector3 sets vertical and horizontal GUI alignments


lihis
 Share

Recommended Posts

Hey, just thought i'd drop this here!

If you move GUI control with moveToVector3 and later try to place another GUI in the same spot using top and left values from the first one; it's not gonna go as hoped due to now different alignments.

Example to be seen here: https://www.babylonjs-playground.com/#GGB8I0

Not a bug technically i suppose, but certainly sent me hunting for one. 🧐

 

I did not expect the alignment to change. No mention of this happening in the docs either (that my eyes could see).

linkWithMesh appears to set alignments as well.

 

Anyhoo, that's all. :)

 

Link to comment
Share on other sites

:) Hi Lihis!  Yep, if you have different alignments for each... you're in trouble.  Good reminder, thx!

But... what if you copy all 4 properties?

button2.horizontalAlignment = button.horizontalAlignment;
button2.verticalAlignment = button.verticalAlignment;
button2.top = button.top;
button2.left = button.left;

https://www.babylonjs-playground.com/#KX33X8#44

(see lines 303-306)

Drag the "drag me" button upward and rightward some distance.

As soon as you do pointerUp, button2 is created directly atop the dragged button.  That seems to work, but there could be more issues.

Gotta be sure your controls aren't inside a stackpanel, which will try to do aligning FOR you.  :) So will grids.

Link to comment
Share on other sites

Hey @Wingnut :)

 

Yeah, copying alignment works. But since i myself had not touched the alignment properties at all, alignment being the issue was completely out of my mind.

It did not occur to me that using moveToVector3 might have changed alignment because i had not changed or used alignments at all. They were just their defaults. And moveToVector3 changed these defaults.

I would have figured it calculates the proper left and top values using whatever alignment you happen to be using - not change the alignment and then do the calculation...

 

Once you know what's up it's not a big thing, but in this case i think what's up is a bit hidden. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...