Godot Version
Godot V4.3 mono stable win64
Question
I’m trying to make a sudoku game.
I have a board GridContainer with 3x3 box PackedScenes instantiated on it. Each box GridContainer has 3x3 tile PackedScenes instantiated as children. Each tile GridContainer has 3x3 possibilityLabel
PackedScenes instantiated as children.
The issue is it takes a while to spawn, especially for large boards.
I first thought I could stop the GridContainers from updating while spawning, then allow updates after, but that didn’t work.
I then tried spawning in one box, and duplicating it, but it was missing it’s children.
I then tried spawning in one box, saving it to file as a PackedScene, and then using it in the future, and it was missing all the children.
I tried changing object ownership but that led to a bunch of mess. My code:
private void TestSaveScene(Control cont)
{
SetOwnerRecursive(cont, cont);
PackedScene scene = new PackedScene();
scene.Pack(cont);
ResourceSaver.Save(scene, $"res://AutoGenerated/box_{width}x{height}.tscn");
}
private void SetOwnerRecursive(Node node, Node owner)
{
if (node.Owner == null && node != owner)
node.Owner = owner;
foreach (Node child in node.GetChildren())
SetOwnerRecursive(child, owner);
}
Is there a way to save a scene with a bunch of PackedScene children as a PackedScene at runtime? Or a better approach to spawning in my board? Thanks.