how to resize element in the CenterContainer

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

Hi i have CenterContainer and TextureRect, can i to resize TextureRect with container?

i want resize TextureRect to 80% of CenterContainer

Ternarycat | 2019-11-24 13:20

:bust_in_silhouette: Reply From: Sogeking

Here’s one solution :

1- Attach a script to your TextureRect.
2- Connect your CenterContainer’s “resized()” signal to your TextureRect
(Click on your CenterContainer and check the “Node” panel)
3- Then on your newly created function, add :

func _on_CenterContainer_resized():
    rect_min_size = get_parent().rect_min_size * 0.8

Your function name may differ if you named your CenterContainer otherwise
4- On your TextureRect, Check the “expand” box just below the texture.

Then as you change your CenterContainer’s min_size (or size, you’ll have to adapt a bit), your TextureRect should adapt