Tencent/xLua logo

Tencent/xLua

Free

xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.

FreeFree tier
Type
Open Source
Company
Tencent

About Tencent/xLua

xLua is an open-source Lua programming solution for C# environments such as Unity, .Net, and Mono. It enables seamless integration of Lua scripting with C#, allowing runtime replacement of C# methods with Lua implementations. Key capabilities include hotfix support for updating live C# code without recompilation, optimized garbage collection with zero allocation for struct and enum passes, and editor‑free development (no code generation needed during editing). xLua supports Android, iOS, Windows, Linux, macOS, and WebGL. The project provides extensive documentation, a rich set of examples (covering HelloWorld, MonoBehaviour scripting, UI events, coroutines, async/await, hotfix, etc.), and active community support via QQ groups.

Key Features

Runtime replacement of C# methods, operators, properties, and events with Lua implementations
GC optimization: custom struct and enum passed between Lua and C# with zero GC allocation
No code generation required in the editor, enabling lightweight development
Hotfix capability: replace C# logic with Lua without modifying original code, low runtime impact
Lua coroutine support seamlessly integrated with Unity coroutines
Async/await support in Lua via coroutine synchronization
Signature loader for reading digitally signed Lua scripts
Cross‑platform: Android, iOS, Windows, Linux, macOS, WebGL
Comprehensive documentation: tutorial, configuration, FAQ, hotfix guide, API docs
Extensive examples covering MonoBehaviour scripting, UI events, object orientation, async patterns, hotfix, and more

Pros & Cons

Pros
  • Open source under an MIT license, free to use and modify
  • Easy to install: download from Releases or clone repo, drop Assets folder into Unity project
  • Hotfix works without altering existing C# code, minimal invasion to legacy projects
  • Good performance with GC optimizations for value types
  • Active community support via dedicated QQ groups (three groups available)
  • Well‑documented with tutorials, configuration guides, and FAQ
  • Rich set of example projects covering many common use cases
Cons
  • Limited to C# environments (Unity, .Net, Mono); not a general‑purpose Lua solution
  • Requires familiarity with both Lua and C# to effectively use the interop features
  • Hotfix usage may have a learning curve for developers new to Lua patching
  • Primary documentation is in Chinese, though English documents are available
  • Dependency on the Lua runtime may increase build size for mobile platforms

Best For

Adding Lua scripting capabilities to Unity games for gameplay logic, UI, and eventsHotfixing production bugs in C# Unity, .Net, or Mono applications without rebuilding the entire projectRapid prototyping of game logic using Lua's fast iteration cycleExtending .Net or Mono desktop/server applications with Lua scripting for modding or customizationEnabling live code updates in deployed applications to fix critical issues

FAQ

How do I install xLua in a Unity project?
Download the latest release from the Releases page or clone the repository. Extract the Assets directory from the downloaded package and place it into your Unity project's Assets folder. The Assets/Examples folder contains sample code and should be removed for production. For installation to other directories, refer to the FAQ documentation.
How can I get support for xLua?
xLua has three QQ groups for technical support: Group 1 (612705778, full), Group 2 (703073338, full), and Group 3 (811246782). Before asking, consult the FAQ documentation as over 90% of questions are answered there.
Can I use xLua to hotfix my deployed Unity application?
Yes. xLua provides a hotfix feature that allows you to replace C# methods with Lua logic without modifying the original code. It is low‑invasion (no changes needed to existing code) and has minimal runtime impact when no patches are applied. See the hotfix guide for detailed instructions.