GridContainer Not Updating Layout on Dynamic Child Addition

Godot Version

4.3 Stable

Question

I have a GridContainer with a specified column count of 2, and I’m dynamically adding multiple TextureRect as children. The problem is that the layout doesn’t update to the 2-column structure when I add children during runtime. Instead, all added children appear in a single column below each other. When I add children before running the scene, the layout respects the 2-column setup as expected.

What I tried

Found in the documentation for Grid Container (but didn’t change anything):

$TheGridContainer.add_child(skinTextureRect)
$TheGridContainer.queue_sort()

Tried Google
Read to all GitHub issues with “Grid Container”
Used the search on forum.godotengine.org

Can you check if the column-amount is also 2 during the game?
Print out “$TheGridContainer.columns”

1 Like

@herrspaten Yes, just checked it every time this gets updated it stays at 2.

But you guided me to the result. Thank you very much!

The issue was that I was looping over files and Godot seems to create duplicates:

File1.png
File1.png.import
File2.png
File2.png.import

.import is not a duplicate file, it’s the import settings for each image.

2 Likes

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