Haxe/C# externs for Godot 3.2.3
Use the Godot engine with Haxe scripting, using the Haxe/C# target.
How to use
Setup a C# project in Godot to have the
.csproj file generated, and in
Your haxe code must be compiled to C# but not natively compiled, this is handled by Godot,
as the project doesn't have a main class you must list all scripts classes in your hxml, or use the
it'll compile all scripts refered in the scenes (this require the scene to be saved after adding a new script).
--cs build -D net-ver=50 -D no-compilation -D analyzer-optimize --class-path scripts --library godot --macro godot.Godot.buildProject() --dce std
Adding a new script is a bit awkward for the moment:
- In Godot right click a node, attach script
- Set language as C#
- Set the path as the generated C# path, for instance if you have your Haxe script as
build/src/some/pack/MyScript.cs(the file won't exist)
- Click on create, it'll open the C# file, ignore it
- In the editor save the scene
- Create your Haxe script
- Build your Haxe code, the C# file opened by Godot is replaced by the C# output of your Haxe script
Godot will show many warnings about the Haxe generated C# code, this is because of https://github.com/godotengine/godot/issues/28293.
A Godot editor plugin will be researched to streamline this process.
See Squash the Creeps 3D sample for an example of a Godot project using Haxe.
Differences with the C# API
- 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
- Export meta for variables is
@:export, C# is
- Haxe has different keywords than C#, if the C# API use an Haxe keyword it'll be suffixed with a
- Mark deprecated functions
- Typesafe signals with support for lambdas
- Array access on
- Missing types
The generated externs and support code are MIT licensed, the original C# externs and the Godot engine are MIT licensed.