Troubleshooting
Appendix. During development you can iterate quickly in the Editor (Mono); for Player issues first confirm ZLua/Generate/All and Compatibility. Start the mainline from Install.
Canonical project: zlua-demo
Install and startup
No Lua output at all after Play
| Check | Notes |
|---|---|
LuaAppDomain.Initialize | Must use [RuntimeInitializeOnLoadMethod(BeforeSceneLoad)] or earlier |
| Console filters | Confirm Log is not hidden |
module 'xxx' not found
| Check | Editor | Player |
|---|---|---|
| File path | {ProjectRoot}/LuaScripts/xxx.lua | StreamingAssets/LuaScripts/xxx.lua.txt |
| Sync | Optional | Sync script is required |
Type and member access
Type is nil
- Assembly name / alias correct? (
CSharp['AC'] = CSharp['Assembly-CSharp']) - Namespaced types need
CSharp.AC['Ns.Type']
Event .get / .set is nil
Deprecated. Use add_OnX / remove_OnX. See Event.
EmmyLua debugging
Breakpoints miss, cannot connect, Play freezes: see EmmyLua debugger (sourcePaths, port, waitIDE).
C# calling Lua
GetFunction ineffective
- Has
LuaAppDomain.Initializerun? - Do module / method match Lua
return { ... }keys? - Does the Lua module
return { method = ... }? - Just after
Reset: old delegates are invalid — re-GetFunction
Second Initialize throws
When a main lua_State already exists, use LuaAppDomain.Reset(loader); you cannot call Initialize again to “swap loader only”. See LuaAppDomain.
Editor OK, Player fails
| Check | Notes |
|---|---|
| Generate | Il2Cpp must Generate C++ stubs |
| StreamingAssets | Was Lua Synced? |
| Deprecated APIs | Do not use Event .get |
Learning path
| Previous | Migration |
| Next | Editor vs Player |