Topic was automatically imported from the old Question2Answer platform.
Asked By
logicor
The document says
SIZE_SHRINK_CENTER = 4 — Tells the parent Container to center the node in itself. It centers the Control based on its bounding box, so it doesn’t work with the fill or expand size flags. Use with size_flags_horizontal and size_flags_vertical.
But somehow it is not working for me. Is there anything besides setting this size_flag required for automatic center alignment to work?
I know how to do it manually in the script but it is kind of a pain in the butt to scripting it for every UI component needs this. Especially when I am using a mix of GDscript and GDNative.
I understand that you want to center a control in the editor?
Select “Center” from the layout button (green button above editor window). Which sets the anchor values of the control to 0.5 each.
(Margin values then indicate the distance from each side of the control to the center.)
Alternatively you should be able to set the anchor values to 0.5 in code if you desire.