⚡
Easier · zero-config
Declarative GetFunction / [LuaMarshalAs], lazy CSharp loading; no per-type C# Wrap allowlist, no raw Lua C API.
🚀
Native C++ interop
Il2Cpp uses native C++ bridges. See the performance report for measured results, test environment, and workload limits.
📦
Smaller bridge · less GC
Signature-shared C++ stubs reduce duplicated bridge code. Low-allocation Marshal paths depend on data types, call direction, and warm-up.
Bidirectional calls at a glance
- C# → Lua
- Lua → C#
C# · GetFunction
// Bootstrap.cs
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void InitZLuaOnStartup()
{
LuaAppDomain.Initialize(LoadLuaModule);
}
Action AppMain;
Func<int, int, int> AppAdd;
void Awake()
{
AppMain = LuaAppDomain.GetFunction<Action>("app", "main");
AppAdd = LuaAppDomain.GetFunction<Func<int, int, int>>("app", "add");
}Lua · app.lua
-- app.lua
local function main()
print("lua main start")
end
local function add(a, b)
return a + b
end
return {
main = main,
add = add,
}CSharp['AC'] = CSharp['Assembly-CSharp']
local function main()
local demo = CSharp.AC.Demo()
demo.x = 10
print("Demo.Add:", CSharp.AC.Demo.Add(3, 5))
end
return { main = main }