Resize children to fit HBoxContainer

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

Hey,

I want to do something like this

And this is what I have

How can i make the icons fit the screen and not overflow?

Thanks :slight_smile:

:bust_in_silhouette: Reply From: MxtApps

I do not know if this is exactly that you want but I tell you how:
-select the HBoxContainer and in the inspector open the transform tab
-check the x and the y size
-attach an script to the HBoxContainer
-write the following code:

extends HBoxContainer


onready var first = $CharacterIconPreview1
onready var second = $CharacterIconPreview2
onready var third = $CharacterIconPreview3
onready var four = $CharacterIconPreview4


var requested_size = Vector2(5, 5) #Input here the values that you previously got.


func _ready():
first.set_size(requested_size)
second.set_size(requested_size)
third.set_size(requested_size)
four.set_size(requested_size)

Warning with the identations

I hope this will be useful for you!!

I do not have a transform tab, do u mean Rect Position?

Toscan0 | 2021-06-28 18:03