haxe externs | editor plugin | demo | api doc | discussions
Use the Godot engine with Haxe scripting, using the Haxe/C# target.
Using the editor plugin plugin is recommended, see the documentation on how to install it, setup a project, using Haxe scripts and building your project.
Godot will show many warnings about the Haxe generated C# code, this is because of godotengine/godot#28293.
- Casing
- Variables and functions use the camelCase formating instead of C#'s PascalCase
- Enums and types still use PascalCase
- Constants use ALL_CAPS
- Due to Haxe's module handling C# subtypes like
Godot.Animation.InterpolationTypearegodot.Animation_InterpolationType
- Export meta for variables is
@:export, C# is[Export] - Tool meta for classes is
@:tool, C# is[Tool] - Haxe has different keywords than C#, if the C# API use an Haxe keyword it'll be suffixed with a
_ - Typesafe signals with lambda support, for improved safety and dce support
signal_namebecome aonSignalNamevariable of typeSignalwithconnect/disconnect/isConnectedfunctions- Replace
mynode.connect("the_signal", myHandler, "myFunction")withmynode.onTheSignal.connect(myHandler.myFunction) - This prevent typos on signal name, function name, and mismatch signature on the connected function or on the
emitSignalfunction - Define your own signals with
CustomSignal<FunctionType>and use it with the same api as the built-in signals
- Typesafe actions
- The
project.godotfile is read for its input action list and used to populate thegodot.Actionenum - You can pass an
Actionto functions likeInput.isActionPressedegInput.isActionPressed(MoveLeft)instead ofInput.isActionPressed("MoveLeft") - This prevents typos on actions and give you autocompletion of the actions
- Note: the patched functions still accept strings as normal
- The
- The
asoperator is a function on godot object, if usinggodot.Utils - Similar to GDScript you can delay a variable initialization until the node is ready by using
@:onready var myNode = getNode("Path/To/Node).as(Spatial);, andmyNodewill only callgetNodeonce_Readyis called
- Mark deprecated functions
- Array access on
Vector2,Vector3,Transform,Transform2D,Quat,ColorandBasis - Missing types
Godot.DynamicGodotObjectandGodot.MarshalUtils - Explicit constructors
- Function with type parameters on
PackedScene.Instance,PackedScene.InstanceOrNull cs.system.EventHandler_1onGD.UnhandledException
The generated externs and support code are MIT licensed, the original C# externs and the Godot engine are MIT licensed.
