Awesome
haxe externs | editor plugin | demo | api doc | discussions
Haxe/C# externs for Godot 3.4.5
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 https://github.com/godotengine/godot/issues/28293.
Differences with the C# API
- 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.InterpolationType
aregodot.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_name
become aonSignalName
variable of typeSignal
withconnect
/disconnect
/isConnected
functions- 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
emitSignal
function - Define your own signals with
CustomSignal<FunctionType>
and use it with the same api as the built-in signals
- Typesafe actions
- The
project.godot
file is read for its input action list and used to populate thegodot.Action
enum - You can pass an
Action
to functions likeInput.isActionPressed
egInput.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
as
operator 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);
, andmyNode
will only callgetNode
once_Ready
is called
TODOs
- Mark deprecated functions
- Array access on
Vector2
,Vector3
,Transform
,Transform2D
,Quat
,Color
andBasis
- Missing types
Godot.DynamicGodotObject
andGodot.MarshalUtils
- Explicit constructors
- Function with type parameters on
PackedScene.Instance
,PackedScene.InstanceOrNull
cs.system.EventHandler_1
onGD.UnhandledException
License
The generated externs and support code are MIT licensed, the original C# externs and the Godot engine are MIT licensed.