31 / GodotOnReady

A C# Source Generator that adds convenient onready-like features to your C# scripts in Godot Mono (3.x) without any reflection.
https://www.nuget.org/packages/GodotOnReady
MIT License
123 stars 13 forks source link

Fix 'OrNull = true' to allow null path #4

Closed 31 closed 3 years ago

31 commented 3 years ago

Fixes this:

[OnReadyPath(OrNull = true)] public Button FullyOptionalButton { get; set; }

to generate this code with the if:

if (FullyOptionalButtonPath != null)
{
    FullyOptionalButton = GetNodeOrNull<global::Godot.Button>(FullyOptionalButtonPath);
}

Right now it doesn't have the if. If nobody specifies the path in the editor, the code needs to avoid calling GetNodeOrNull or we'll crash.