xLua (Tencent/xLua)
Searching Database…
What is this?
xLua adds Lua scripting to C# environments — Unity, .Net and Mono — so Lua code and C# can call each other easily, typically to script Unity games.
Where does the Lua actually run — does xLua bundle its own interpreter?
Yes. Each LuaEnv instance you create corresponds to a Lua virtual machine, and the README recommends keeping exactly one instance, globally unique, to limit overhead.
How do I add it to my Unity project?
Download a build from GitHub Releases (or grab the repo code), then drop the contents of its Assets directory into your project's Assets folder, keeping the structure. Remove Assets/Examples before shipping to production.
Do I need anything else installed alongside it?
No — it installs as plain source inside your Unity project with no external steps. If you later want third-party Lua libraries, there is a dedicated guide for adding or removing them.
Is the hot-fix feature ready to use out of the box?
No — it has to be enabled first; the 08Hotfix example notes you should follow the hot-fix guide in the docs to switch it on.
Will it work in mobile builds, or only desktop?
Mobile is first-class: the project supports android and ios alongside windows, linux and osx.
What can I actually do with the Lua side?
The bundled examples show writing MonoBehaviours and UI logic in Lua, mixing Lua OOP with C#, running Lua coroutines alongside Unity's (even turning async code synchronous), calling generic methods, loading digitally signed scripts, and re-implementing C# value types in Lua.
How much code for a hello world?
Three lines: create a LuaEnv and call DoString with any valid Lua code — the quickstart logs via C#'s UnityEngine.Debug.Log from inside Lua. C# can call back into Lua too, for example grabbing a Lua function from the global table.
What is the hot-fix feature good for?
It replaces C# methods, operators, properties and events with Lua implementations at runtime. Old projects need no code changes, and until a patch actually fires the program behaves as before — so problems in an already-released build can be fixed with Lua.
Is there anything special about performance?
Yes — xLua highlights GC optimizations: custom structs and enums cross between Lua and C# with zero C# GC allocations. It also skips code generation while working in the editor, keeping the dev loop lightweight.
What are similar projects?
nakama, UniTask, AssetStudio, unity-mcp, UnityCsReference, osu, MonoGame, Cpp2IL
