#Tool script has set accessor that runs before _Ready
2 messages · Page 1 of 1 (latest)
Not really, exported properties are set right after an object is created since it's possible to export properties from non-Node scripts (mostly Resources). You might want to use IsInsideTree for checks, or just don't interact with the tree in the setter.
I usually "solve" like that
public class Foo : Node
{
private string text;
[Export] public string Text
{
get => text;
set
{
text = value;
if (IsInsideTree()) UpdateLabelText();
}
}
public override void _Ready()
{
UpdateLabelText();
}
private void UpdateLabelText()
{
var label =... //safe method to get nullable label, probably just a field
if (label == null) return;
label.Text = text;
// something extra
}
}