Configure Lua support¶
Tick UI ships its Lua layer as an opt-in assembly. It compiles only
when both the TICK_LUA scripting define is set and the MoonSharp
interpreter is present. As a result, it has zero impact on projects
that do not use it. Enable it in three steps.
1. Install MoonSharp¶
Install MoonSharp through OpenUPM as com.toxicbloud.moonsharp. It
ships an assembly named MoonSharp, with the C# namespace
MoonSharp.Interpreter. The scripting assembly references that
assembly by name.
If you instead add MoonSharp as a precompiled DLL, reference it
through the scripting assembly's precompiledReferences rather than
the named MoonSharp reference in its .asmdef.
2. Define TICK_LUA¶
Add TICK_LUA under Project Settings > Player > Other
Settings > Scripting Define Symbols, for each platform you
build. With the define set and MoonSharp present, the
interludesoftware.tick.scripting assembly compiles, and
TickLuaApi and LuaScriptRunner become available.
The define and the dependency go together
Setting TICK_LUA without MoonSharp installed causes compile
errors. The scripting assembly cannot resolve the MoonSharp
reference. Install MoonSharp first, then add the define. The
reverse is harmless. With MoonSharp present but TICK_LUA
unset, the assembly is excluded from compilation and the layer
stays dormant.
3. Prepare IL2CPP and WebGL builds¶
Ahead-of-time players such as WebGL and IL2CPP strip managed code
that only Lua reaches at runtime. The scripting assembly ships a
link.xml that preserves the types it binds. When you expose an
extra type to Lua, such as a game-state view object, add a matching
<type> entry to that link.xml so it survives stripping. For an
example, refer to Run your first Lua script.
Verify it compiled¶
After Unity recompiles, the interludesoftware.tick.scripting
assembly appears in the project and LuaScriptRunner resolves in
code. A "type or namespace MoonSharp could not be found" error, or
a missing-assembly-reference error, means MoonSharp is not installed
or not resolvable. Revisit step 1 before the define in step 2.
Additional resources¶
- Run your first Lua script: host the runner and write a script once the layer compiles.
- Compile flags: the full set
of Tick UI scripting defines, including
TICK_LUA.