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

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.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