I'm a beginner who's feeling really stupid right now.
I have a scene HexTile (Node2D) with a child Label (Label), added through the scene editor.
I have another scene Board (Node). Board is meant to be the main scene.
Each scene has a C# script.
Board instances, and adds as children, several HexTile scenes through its script and stores them in a collection.
It then attempts to access the Label of each HexTile and set its text.
The Label is not found; the debugger claims "object reference not set to an instance of an object".
The relevant code looks something like this:
public class Board : Node
private HexTile _hexes;
public override void _Ready()
_hexes = new HexTile;
for (int i = 0; i < 10; i++)
var hex = new HexTile();
I've confirmed that the HexTiles get properly added as child scenes of Board as, without the call to Label, they get placed and drawn properly.
I've confirmed that Label is properly added to HexTile, as it displays properly when running the HexTile scene in isolation, and accessing Label and editing its text works.
I get the same error if I move the Label-accessing line to the script of HexTile and run the project with Board as the main scene. (HexTile still runs fine in isolation.)
I cannot, for the life of me, figure out what I'm doing wrong here. Please help me!
Thank you in advance!