Trying to make a very basic custom container [SOLVED]

Godot Version

Godot_v4.3-stable_win64

Question

`
Hi, i tried to make a very basic custom container in godot 4.3 but i can’t make it work. I created a brand new empty project, created a new container and gave it a script that i copy pasted from the documentation :

rect_size is an error so i change it for Vector2(400, 400)

for now because i just want to make it work and learn containers before adding to it and making what i need.

So here is what i have: a container with:

extends Container

func _notification(what):
	print(what)
	if what == NOTIFICATION_SORT_CHILDREN:
		# Must re-sort the children
		for c in get_children():
			# Fit to own size
			fit_child_in_rect(c, Rect2(Vector2(), Vector2(400, 400)))

func set_some_setting():
	# Some setting changed, ask for children re-sort.
	queue_sort()

But whatever i do it doesn’t work. I am new to Godot from Unity so i’m still learning new things like this.

Thank you for everyone who pass here :blue_heart:.
`

Here is a screen shot if needed. The script on the container is on first post


New project so that nothing else can break it. Trying to make one that work before adding one in the game that i develop.

Does it work if you run your game?

Scripts don’t run in the editor by default. You’ll need to make it a @tool script. More info here Running code in the editor — Godot Engine (stable) documentation in English

Oh never hear of @Tool before. Yes sorry i forgot about this, it works when i run it.

It’s definively @Tool that i needed, thx again for making me aware of it.

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