How to center scale a button with text inside a VBoxContainer

Godot Version

4.2.1

Question

Hey there fellas!

I’ve been trying to make a button that scales up when the mouse is over it
but when I do that, the button and the text doesn’t seem to be centered

footage-2024-01-22_10.03.27-ezgif.com-optimize

here’s the Scaler code:

Screenshot_2024-01-22_10-03-08

And the scene structure:

Screenshot_2024-01-22_10-02-07

I have tried many solutions, but I didn’t figure out what is wrong

I centered everything in the button:

Screenshot_2024-01-22_10-02-54

Even the pivot:

Screenshot_2024-01-22_10-02-33

BUT none of it fixed it
Anyone can help me??

put the button inside a control Node first

Nope, Didn’t fix :frowning:

playbutton

image

I did that but it still doesn’t center, is there like another sizing variable other than the Scale one??

it’s matter of how you layout the control and button etc
i will need to screenshots alot

VBoxContainer:
image

Control Node:
image


image

PlayButton Node:
image

the Script

var tw=create_tween().bind_node(%PlayButton).set_loops(-1).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_SINE)
tw.tween_property(%PlayButton,"scale",Vector2(1.2,1.2),2).from(Vector2.ONE)
tw.tween_property(%PlayButton,"scale",Vector2.ONE,2)

GIF:
playbutton2

2 Likes

You need to set the Control.pivot_offset to the center of the button.

2 Likes

OH MY GOD THANK YOU SO MUCH!! it worked!!
i apologies my knowledge of UI is limited, And thanks again!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.