Godot Version
Godot 4.2.2
Question
Hi! For background, I’m new to Godot but I have extensive working experience with Unity. Please direct me if there’s a better way of doing what I’m trying to do.
I’m making a Sudoku app as my first Godot project to come to grips with the Godot way of doing things. The 9x9 sudoku grid is 81 tiles, each of which is an instanced Scene including a label, and their own 3x3 grid of “pencil” numbers. In Sudoku games, it’s common to have each little square have a 3x3 grid of which numbers you think could go in that square. So we’re looking at 9x9 = 81 “Square” nodes, and 9x9x9 = 729 “Guess” Label nodes total, at the very least.
To that end, I figured I’d use the custom Canvas drawing to re-draw them when changed, rather than actually maintain all the Control nodes simultaneously.
I’d like to be able to take a Scene of Label nodes, a 3x3 grid of Label laid out with the GridContainer, and render them to a Texture2D.
My question is: How do I go about doing this? I spent today going through the documentation and trying (and failing) to get a ViewportTexture to show up. I can confirm that a SubViewport drew correctly to my ViewportTexture inside a TextureRect inside that scene. However, getting it to draw/copy to an ImageTexture doesn’t seem to be happening. Maybe I’m doing something wrong. If so, please spell out the steps that I should be taking from here, assuming that the ViewportTexture is as I expect it to be.
Alternatively, is there a better way of doing this, by overriding the _draw method of CanvasItem (on perhaps a Control with a script on it?)