[Export]
private bool IsSymbolFixed
{
get => isSymbolFixed;
set
{
isSymbolFixed = value;
SetFixed(value);
}
}
Whenever I build my project, set is executed. This results in errors with Nodes not being set at this point further down the line. Is there a way to check from where a set is coming to prevent the inspector triggering the execution of SetFixed() on each successful build?
Is there a way to check from where a set is coming […]
Nope.
I suppose you could add some checks before calling SetFixed, depending on the errors you’re getting? Like null checks, or using some initialized boolean that you set to true only when the node and its children are properly initialized, meaning you can call your method safely.
I find it strange that the setter is called “whenever you build” though, but what do you mean exactly? Is it called when launching a build, or during the build process, or something else? You’re talking about a successful build so I suppose we’re talking about the build execution, but I’m not sure I understood exactly when the errors are poping.
Could you share the error/exception message? It should contain the stack trace of instructions leading to the property’s setter and give more context about what’s happening.
It’s just a System.NullReferenceException, but I’m guessing that’s not exactly relevant to the question since the error itself is not my issue, but the triggering of set by the inspector after a build
I understand that, but could you share the complete stack trace leading to the System.NullReferenceException? It should give you more info about where the call is coming from. And from there, we may notice something and have a better understanding of why the set is called.
This seems related to some Godot’s building serialization stuff, sadly I don’t understand the details of what’s going on so I cannot help a lot to explain exactly why this is happening
I was hoping to find a preprocessor define like “GODOT_EXPORTING” that would have allowed you to write something like that:
It’s because your properties is exported and probably set in the editor. You can have a check to determine if your node is ready or change your exported properties for the masked one isSymbolFixed instead.