Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | chanon |
For example, I have a GridContainer
inside a ScrollContainer
.
In _ready()
I add items into the GridContainer
(a list of level buttons).
I need to scroll the ScrollContainer
so the last level that the player reached is visible.
So I need to get the position of the button for the level and then update the ScrollContainer
scroll_vertical
value.
Using a simple yield(get_tree(), "idle_frame")
does not work.
Running it once in _process()
does not work.
However if I leave it running for all frames in _process()
, then it does work. (But then the ScrollContainer
is stuck at that position.)
It seems like it takes multiple frames for it to get the final positions.
Also, I’m not sure, but it may also be related to visibility somehow. Ie. if the thing is not visible on screen yet (visibility of itself or an ancestor is false), then it will not get correct positions yet.
This makes it very frustrating when you need to programmatically position things.
Is there a method that can just be called to get everything into position so I can do programmatic positioning?
As it is, I don’t know how to implement this.