+2 votes

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.

Godot version godot 3.2 stable
in Engine by (5,557 points)

1 Answer

0 votes

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 sizeintile_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.

by (98 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.