Unity3D:Xlua发布WebGL端注意事项
坨坨号拖拉机 2024-08-09 16:33:01 阅读 97
XLua下载地址:GitHub - Tencent/xLua: xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.
1.【WebGLPlugins】文件夹不能漏,放在和【Assets】同级目录;
2.Examples文件夹下的示例可删除,但要保留ExampleGenConfig.cs
3.发布如果遇到报错:Building Library\Bee\artifacts\WebGL\GameAssembly\release_WebGL_wasm\u9l0bh9rzmed.o failed with output:
In file included from Assets/Plugins/WebGL/xlua_webgl.cpp:31:
C:\Users\admin\Downloads\xLua-master\WebGLPlugins\lundump.c:237:33: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
checkliteral(S, LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */
~~~~~~~~~~~~~~^~~
C:\Users\admin\Downloads\xLua-master\WebGLPlugins\lundump.c:237:33: note: use array indexing to silence this warning
checkliteral(S, LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */
^
& [ ]
In file included from Assets/Plugins/WebGL/xlua_webgl.cpp:35:
C:\Users\admin\Downloads\xLua-master\WebGLPlugins\i64lib.c:409:34: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
snprintf(temp, sizeof(temp), "%"PRIu64, n);
解决办法:打开WebGLPlugins > lundump.c 第237行
checkliteral(S, LUA_SIGNATURE + 1, "not a");修改为checkliteral(S, & LUA_SIGNATURE[1], "not a");
然后打开WebGLPlugins > i64lib.c 第407和409行
%后面加空格如下
报错解决!
4.如果发布报错:Assets\XLua\Gen\UnityEngine_LightWrap.cs(1263,35): error CS1061: 'Light' does not contain a definition for 'shadowRadius' and no accessible extension method 'shadowRadius' accepting a first argument of type 'Light' could be found (are you missing a using directive or an assembly reference?)
解决办法:Generator.cs第1472行,BlackList内添加以下内容:
new List<string>(){"UnityEngine.Light", "shadowRadius"},
new List<string>(){"UnityEngine.Light", "SetLightDirty"},
new List<string>(){"UnityEngine.Light", "shadowAngle"},
new List<string>(){"UnityEngine.Light", "shadowAngle"}
5.发布WebGL前要点编辑器窗口XLua > Generate Code生成一下脚本,不然发布会报错,每次修改Lua相关代码后都生成一下
6.如果要修改XLua所在目录,要同时修改一下Generator.cs中生成脚本的路径
7.如果XLua的Plugins/WebGL/xlua_webgl的所在目录被修改,要打开此脚本修改路径
不然会报错Building Library\Bee\artifacts\WebGL\GameAssembly\release_WebGL_wasm\lxh17ydzyhzx.o failed with output:
C:\Users\admin\Downloads\xLua-master\Assets\XLua\Plugins\WebGL\xlua_webgl.cpp:2:10: error: '../../../WebGLPlugins/lapi.c' file not found, did you mean 'WebGLPlugins/lapi.c'?
#include "../../../WebGLPlugins/lapi.c"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
最后:不要忘了发布WebGL前要点编辑器窗口XLua > Generate Code生成一下脚本,以上每一条都是我踩过的坑。
声明
本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。