Godot Version
4.2
Question
I have a HBoxContainer with buttons. I made scale = 0.75 and made anchors_preset cleft at the bottom, but because of the scale, it is not placed correctly. How can I do this without calculating the pivot?
4.2
I have a HBoxContainer with buttons. I made scale = 0.75 and made anchors_preset cleft at the bottom, but because of the scale, it is not placed correctly. How can I do this without calculating the pivot?
You probably shouldn’t use scale here. You can set the size of the HBoxContainer to be smaller, and unless the children have a custom_minimum_size larger than that, they will be made to fit.
Note that Buttons do have minimum sizes by themselves. For example, the smallest a button with no text can be is 8x8. With the default font, it’s however-long-the-text-isx31. In your case, if the container won’t get any smaller when you lower it’s size.y, it’s probably because of the images.
If you are using TextureButtons, enable ignore_texture_size and set a custom_minimum_size on the button itself. Change the strech_mode to something that fits your fancy, probably Keep Aspect.
Why not just move the pivot to the bottom of the container?
Do the calculations for each resolution separately? It’s sad
There’s no need to calculate anything. The position of the bottom edge at non-scaled size is known. Once you put the pivot there, it’ll stay there regardless of scaling.