You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automatic C# bindings generator for GDExtension classes (Godot 4.4+)
How to use
Import your GDExtensions
Enable the C# GDExtension Bindgen plugin in Project Settings... -> Plugins tab
Click in the menu item Project -> Tools -> Generate C# GDExtension Bindings whenever you want to regenerate C# bindings
Enjoy 🍾
How does it work?
This editor plugin contains the script csharp_gdextension_bindgen.gd with the whole C# code generation.
It uses the reflection provided by ClassDB to generate bindings to enums, constants, properties, methods and signals for all classes registered using the GDExtension API.
The generated C# classes are in the GDExtensionBindgen namespace, so you'll need to add using GDExtensionBindgen; before using them.
The generated classes do not inherit from any GodotObject subclass because they are not C# scripts attached to the native objects, but rather a thin C# wrapper with strongly typed definitions of all members registered. Most of the time this addon tries to generate code that matches what Godot generates for C# for engine classes, e.g. you'll see StringNames cached using the PropertyName, MethodName and SignalName nested classes.
Caveats
Since generated classes do not inherit GodotObject, there's no easy way to create C# scripts that specify the wrapped GDExtension classes as their base class
Generating bindings from the CLI
This addon also contains the cli_entrypoint.gd script that can be used to generate bindings via command line:
# Generates C# bindings for all GDExtension classes# Optionally pass the desired output directory and C# namespace
godot --headless --script addons/csharp_gdextension_bindgen/cli_entrypoint.gd -- [OUTPUT_DIR] [NAMESPACE]
This can be used by GDExtension projects themselves as a way to distribute pre-generated C# bindings.
TODO
support constant integers that are not part of any enum
get/set properties inherited from engine class directly without Get/Set
support signals
submit to the Asset Library
cache StringNames
support packed arrays as method default values
support non-empty Arrays and Dictionaries as method default values
About
Automatic C# bindings generator for GDExtension classes (Godot 4.4+)