- 下载lua源码
首先去lua的官网下载lua:http://www.lua.org/ftp/ 这里测试用的是:1.5.5
- 编译脚本
保存下来脚本到mylua.bat到lua的目录下,然后用Visual Studio Tools》Developer Command Prompt来运行这个bat就可以了,会在src下面生产一个lua515vc.dll
cd src
cl /02 /W3 /c /DLUA_BUILD_AS_DLL l*.c
del lua.obj luac.obj
link /DLL /out:lua515vc.dll l*.obj
cl /02 /W3 /c /DLUA_BUILD_AS_DLL lua.c
link /out:lua.exe lua.obj lua515vc.lib
cd ..
- unity调用
因为是在win32的系统下测试,将生成的dll,放到unity的Plugins/x86下。 参考:https://github.com/phardera/unity3d_lua 类似如下代码,就可以直接使用了:
[DllImport("lua514vc")] private static extern IntPtr luaL_newstate();
ps:官方文档有说明:win32必须放在Plugins/x86下面,否则会出现DLL找不到的错误提示 http://docs.unity3d.com/Manual/PluginsForDesktop.html
- unity_lua_win:https://github.com/phardera/unity3d_lua
- unity_lua_ios:https://github.com/phardera/unity3d_lua_ios