Godot引擎编译添加.NET支持
Godot引擎编译添加.NET支持
看这篇之前确保你已经看过上一篇,已经能正常编译Godot了。
环境依赖
装 .NET SDK 8.0+ (官方链接)[https://dotnet.microsoft.com/zh-cn/download/dotnet/8.0],运行下面命令看看装好没:
dotnet --info
dotnet --list-sdks
编译.NET支持
创建目录Nuget设置NuGet本地源
找一个目录创建本地源目录然后执行命令添加本地源等会要用到。
dotnet nuget add source D:\dev\LocalNugetSource --name MyLocalNugetSource
编译时启用.NET模块
编译脚本里加上 module_mono_enabled=yes:
scons platform=windows target=editor dev_build=yes module_mono_enabled=yes
生成胶水代码
编译完以后,运行编译出来的 Godot 生成胶水代码:
.\bin\godot.windows.editor.dev.x86_64.mono.exe --headless --generate-mono-glue modules/mono/glue
成功的话会在 modules/mono/glue 下生成 Godot API → C# 的自动绑定代码。
编译托管库
上一步跑完后,运行这个生成最终托管库并推到我们的托管库就完成了:
python ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --push-nupkgs-local D:\dev\LocalNugetSource
导出模板
导出模板的流程差不多,完整顺序是这样的:
编译 Mono Editor
↓
generate-mono-glue
↓
生成 MyNode.cs 绑定
↓
build_assemblies.py
↓
编译 Template
或者
编译 Mono Editor
↓
编译 Template
↓
generate-mono-glue
↓
生成 MyNode.cs 绑定
↓
build_assemblies.py
走完上面的 .NET 编译步骤后,正常编译模板就行:
scons platform=windows target=template_debug arch=x86_64 module_mono_enabled=yes