Hello, Luny! Lua Scripting For Unity!

Luny is the first workable Lua scripting solution for Unity!

Since early 2025 I have been busy doing the thing I’ve wanted to do for a decade but didn’t consider it viable: Lua scripting for Unity. 🤓

Not like existing “solutions” just dumping the Lua core code to you and calling it a day. No, no. I’m actively porting Unity’s API and features to Lua. A real integration effort!


Lua Scripting At A Glance

You can add a LunyScript component (or several) to a GameObject and implement all Unity callbacks (Awake, Update, OnCollision, etc) in a Lua script. Simple ways to exchange data and function calls between Lua and C# exist. Mix and match C# and Lua as you see fit.

Here’s an example script LunyTankHealth.lua:

Lua Scripting Example

A scene-wide Luny component serves as an entry point for settings and detached scripts, for instance to plug in your own Lua code libraries and extensions.

There is no domain reload when changing Lua scripts. Perfect for quick iteration cycles and explorative coding.

Unity coroutines as Lua functions also work! Took me just around four weeks … ugh. But worth it!

In The Works …

In the future I will enable autogenerated Unity API bindings, add hot script reload, more debugging tools, and workflow optimizations such as bindings of Inspector serialized fields with Lua script variables.

Oh and … loading Lua scripts from path rather than asset. For modding and development work in a build. Such scripts would default to be in StreamingAssets but optionally the game can specifiy search paths (eg under AppData) where scripts are looked up, and those of the same name take precedence.

Test-Fooding the Dog of Concept

I am test-driving, concept-proofing, dog-fooding Luny development by porting Unity’s Tanks! project and other Unity Learn projects to work out any kinks with code that I personally wouldn’t have written that way (avoid developer bias).

Unity is running a Learn-Along until May 21st, 2025 with the Tanks! remastered project. Simultaneously I will port this Tanks! 3.0 project to Lua again and share the Lua scripts on GitHub. I had just finished porting the classic Tanks! project.

Relevant Links

Review the Script Reference and the Tanks! demo project.

Subscribe to my Patreon to learn about Luny’s release and development progress.

There’s also a Unity Discussions thread if you prefer to comment over there. I’m not actively running/following other social media channels but that is likely to change over time.

– Steffen “CodeSmile” Itterheim

CodeSmile

CodeSmile

Game Engineer and Code Composer since 1999

Leave a Reply

Your email address will not be published. Required fields are marked *