Skip to content

Instantly share code, notes, and snippets.

@Shilo
Created December 3, 2024 18:18
Show Gist options
  • Save Shilo/7455417ddc05bdd74b186be1f6ce6694 to your computer and use it in GitHub Desktop.
Save Shilo/7455417ddc05bdd74b186be1f6ce6694 to your computer and use it in GitHub Desktop.
Godot 4 GodotObject helper methods.
public static partial class GodotObjectExtension
{
public static GodotObject NewWithScript(this GodotObject obj, Variant? script)
{
script ??= new Variant();
ulong id = obj.GetInstanceId();
obj.SetScript(script.Value);
return GodotObject.InstanceFromId(id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment