Skip to main content

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​

CheckNotes
LuaAppDomain.InitializeMust use [RuntimeInitializeOnLoadMethod(BeforeSceneLoad)] or earlier
Console filtersConfirm Log is not hidden

module 'xxx' not found​

CheckEditorPlayer
File path{ProjectRoot}/LuaScripts/xxx.luaStreamingAssets/LuaScripts/xxx.lua.txt
SyncOptionalSync script is required

Type and member access​

Assembly / type not found​

  • No longer silently returns nil: errors look like zlua: assembly not found: … / zlua: type not found: …
  • Check assembly name / alias (CSharp['AC'] = CSharp['Assembly-CSharp'])
  • Namespaced types need CSharp.AC['Ns.Type']

zlua: member not found: Type.key​

  • Spelling, whether public, whether statics were accessed on an instance (or vice versa)
  • Whether extension methods are configured on that type (see Extension)
  • To probe whether a key exists: use rawget or pcall; do not rely on __index returning nil

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.Initialize run?
  • 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​

CheckNotes
GenerateIl2Cpp must Generate C++ stubs
StreamingAssetsWas Lua Synced?
Deprecated APIsDo not use Event .get

Learning path​

PreviousMigration
NextEditor vs Player