To all... I am building a UI for a game scene and i wanted a rotated label.... understanding that the parent container controls that.

So i rotated the container, which works, but not only does it not 'retain' these settings, but getting the size of the container to work as well seems to be tricky...

to a very specific point, the text of the label seems to be growing the size of the margin container its in, which makes sense... but... since its rotated, i expected it to grow in the y direction (-90 degrees rotation), but its still growing horizontally, which of course is throwing off how the UI is built

thoughts?!

attached are images showing how the UI's supposed to look, also when Text is in the rotated label/container, how its pushing out the UI

Adding my node tree in case it helps

Which of the containers have you rotated? VBoxContainer above the MarginContainer2 that is the parent of the PLAYERNAMESUMMARY Label?

Generally speaking though, yeah. Containers will try to update to well, contain their children so if you want more stability and predictability then using a bog standard panel and some custom scripting might be the way to go. Note that you can also make your script a tool script so it will work within the editor too.

i rotated the MarginContainer2

Containers will automatically handle the transform (position, rotation, scale) of any nodes that are their direct children, at least that seems to be how it is based on my experience.

A way around this is to make a child node and then rotate that, so the parent will be transformed by the container but the child node will retain it's offset in rotation/position/etc. For example, if you have a setup like this:

  • Container (HBoxContainer for example)
    • NodeToRotate

Then you could add a child node between the node you want to rotate and the container:

  • Container
    • NodeToRotate_Holder
      • NodeToRotate

Then you should be able to rotate the NodeToRotate node freely without any issues. I would recommend making the NodeToRotate_Holder a Control node, so all it handles is the positioning of the node.

One major downside of this method though is that the rotated Label will NOT be taken into account when positioning and sizing other elements in the container, only the NodeToRotate_Holder node will. This means that if you have your label rotated by 90 degrees and it's vertical size is greater than NodeToRotate_Holder's size on the Y axis, it will not properly move the nodes around down and out of the way, the label will instead just display text over whatever may be underneath. The way around this is to dynamically resize NodeToRotate_Holder so it's minimum size is always big enough to encapsulate the Label, but that can be tricky.

Is this what you intended?

  • Container
  • * NodeToRotate_Holder
  • NodeToRotate

@Mookie said: Is this what you intended?

  • Container
  • * NodeToRotate_Holder
  • NodeToRotate

Yeah, that is what I was meaning. I got the formatting incorrect for the indented lists :sweat_smile: Edit: Fixed it!

Thanks, i'll try tonight and let ya'll know

a year later