A high-performance Lua 5.2 interpreter implemented in C# for seamless scripting in .NET and Unity applications.
Lua-CSharp is a Lua 5.2 interpreter implemented entirely in C#, allowing developers to embed Lua scripting into .NET and Unity applications. It solves the need for high-performance, low-overhead Lua integration by providing a pure C# implementation that avoids the allocation and interoperability issues of alternatives like MoonSharp and NLua.
.NET and Unity developers who need to embed Lua scripting for game logic, modding, configuration, or runtime extensibility in their applications.
Developers choose Lua-CSharp for its seamless C#/Lua interoperation without external dependencies, excellent performance in AOT environments like IL2CPP, and modern async/await support that simplifies asynchronous scripting workflows.
High performance Lua interpreter implemented in C# for .NET and Unity
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implemented entirely in C#, eliminating overhead from C bindings and ensuring reliability in AOT environments like Unity IL2CPP, without requiring IL generation.
Native support for asynchronous operations within Lua scripts, allowing seamless use of C# async methods and simplifying game logic with coroutines, as shown in the async function examples.
Optimized for low allocation and fast interoperation, with benchmarks showing it outperforms MoonSharp and NLua in C#/Lua interaction, as detailed in the README's performance comparison.
Uses [LuaObject] attribute with source generation for automatic C# class binding, reducing boilerplate code for custom types and enabling compile-time error checking.
Uses UTF-16 instead of Lua's standard single-byte encoding, which can break string operations and library functions that assume byte-based strings, leading to compatibility issues with existing Lua scripts.
Not all Lua 5.2 standard library functions are supported, requiring workarounds or custom implementations for missing features, as admitted in the README's compatibility section.
LuaState is not thread-safe, preventing concurrent access and limiting its use in multithreaded applications without additional synchronization, which is a noted warning in the quick start section.
Relies on .NET's garbage collector instead of Lua's, leading to different memory management behavior that might affect script performance and resource cleanup, as explained in the compatibility notes.
Lua-C# is an open-source alternative to the following products:
NLua is a bridge between the .NET platform and the Lua programming language, allowing Lua scripts to be embedded and executed within .NET applications.
MoonSharp is a Lua interpreter written entirely in C# for .NET platforms, enabling Lua scripting integration in Unity games and other .NET applications.