How to set the size of a TextureRect through code?

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

Hi,
Is there a way to set the size of a TextureRect through code?
Please help.

i guess rect_size is not working, so i would go with rect_scale

Andrea | 2021-08-25 18:39

:bust_in_silhouette: Reply From: MisterMano

You should be able to set its size with the function set_size, like this: $TextureRect.set_size(Vector2(100,50))

Thanks again, MisterMano.
This works.

ashish | 2021-08-26 18:45

Bro how can you do that in godot 4. Is it the same.

idk534475689.aiman | 2023-04-23 18:55