Need help with Control Nodes resizing

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Inces

I have a terrible Issue of Panel Container not keeping its anchors after visibility is changed.
He has a Label as a child, and some Panels. It is a known issue that text resizes Label along with its parents, but removing the text doesn’t make them shrink back. It requires to manually be resized by setting rect_size to minimum rect size. However visibility goes insane with this setup - whenever Panel Container is manually resized and visibility is changed - Panel Container shifts position to the left. This happens on all possible size flags combinations, with pivot set to middle of the node, anchor to the top center, grow directions to BOTH. Simple resizing node works fine, simply changing visibility also works, only when both are applied ( regardless of calling order ) shifting happens. It is not possible to simulate in editor, runtime only.

:bust_in_silhouette: Reply From: codelyok13

If this issue is still persisting, you may want to just control the size of your nodes and their positions directly.

You can do this by using using a Vector2D or Vector3D(if you want z-sorting).

  1. Determine how many tiles tall and wide you want to split the screen into
  2. Determine the position and size of the controls in you tilemap
  3. Determine the size of the panel, probably best done in resize
  4. Determine the ratio using the size of the panel divided by the tall and wide of tilemap
  5. Use a for loop going through tile map to set the controls position to what the tilemap says and the size to the size_in_tile_map * ratio

By doing the above you will be able to automatically resize items at runtime. If you want z ordering, use the z of Vector3 to set the Z-Index for the control.