The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Hi,

Im having problems arranging nodes created on-the-fly within a scene. They seem to be laid on-top of each other. The idea is to create a table of lines.

My 'Main' scene has this structure of nodes:

Main
---ScrollContainer
------VBoxContainer

and my 'LineScene' has this structure of nodes:

ColorRect
---Label

My Main.gd script preloads the LineScene and adds 10 new instances of this scene as children of VBoxContainer as follows:

extends Node2D

onready var line = preload("res://line_scene.tscn")

func _ready():
    for n in range(10):
        var new_line = line.instance()
        $ScrollContainer/VBoxContainer.add_child(new_line)
        #self.add_child(new_line)
    pass

I would like each line_scene instance to be arranged beneath the previous one automatically, as expected with a VBoxContainer.

What am I doing wrong? I have tried changing the size-flags of the line-scene nodes and the VBoxContainer separation but with no desired result.

Thanks

in Engine by (92 points)

2 Answers

0 votes

enter image description here

u made scroll and vbox layout full rect? what is scroll rect size?

by (1,975 points)
0 votes

It is min rect size property. Children of BoxContainer lay on top of each other if min rect size of the root most item of any of the children is left default (0, 0).

by (43 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.