timotimosky / luajit2vm Goto Github PK
View Code? Open in Web Editor NEW对tolua的webgl适配
对tolua的webgl适配
Unity 2017没问题,但是升级到Unity 2021就不行了
build的时候报luaopen_socket_core
或者luaopen_cjson
找不到之类的error,但是将lua-cjson
/luasocket
源码放进去编译仍然失败
从LuaDLL.cs
里看到
/*
** third party library
*/
...
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int luaopen_socket_core(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int luaopen_mime_core(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int luaopen_cjson(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int luaopen_cjson_safe(IntPtr L);
...
疑问:
LuaDLL.cs
里指明了需要这些第三方库函数,但是Assets/Plugins/WebGL
里只有LuaVM源码,没有lua-cjson
/luasocket
源码,为什么Unity 2017能够成功build?
你好,我使用这个demo,利用Lua/Build Luajit bundle files (PC) Editor工具打包由Luajit编译的Lua btyescode ab,Assets/Lua/Main.lua会被编译成字节码然后打包进ab:
使用Unity版本是2020.3.34fl,修改了测试代码有关Unity版本的编译宏,以跑和Unity2017一样的代码流程。
修改了LuaState源码,直接加载Main.lua:
void OpenBaseLuaLibs()
{
//DoFile("tolua.lua"); //tolua table名字已经存在了,不能用require
DoFile("Main.lua");
LuaUnityLibs.OpenLuaLibs(L);
}
打包webgl平台,起服务器运行,结果Lua解析不了bytescode:
相反没有编译bytescode的源码却可以正常解析运行,即利用Lua/Build bundle files not jit打包的lua ab:
请问有什么方法可以令这个框架发布webgl平台,正常运行由Luajit编译出的bytescode吗?感谢解答!:heart:
如题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.