Unity3D:Xlua发布WebGL端注意事项

04-23 1238阅读 0评论

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】同级目录;

Unity3D:Xlua发布WebGL端注意事项

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);

Unity3D:Xlua发布WebGL端注意事项

解决办法:打开WebGLPlugins > lundump.c 第237行

Unity3D:Xlua发布WebGL端注意事项

checkliteral(S, LUA_SIGNATURE + 1, "not a");修改为checkliteral(S, & LUA_SIGNATURE[1], "not a");

Unity3D:Xlua发布WebGL端注意事项

然后打开WebGLPlugins > i64lib.c 第407和409行

Unity3D:Xlua发布WebGL端注意事项

%后面加空格如下

Unity3D:Xlua发布WebGL端注意事项

报错解决!

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?)

Unity3D:Xlua发布WebGL端注意事项

解决办法:Generator.cs第1472行,BlackList内添加以下内容:

new List(){"UnityEngine.Light", "shadowRadius"},
new List(){"UnityEngine.Light", "SetLightDirty"},
new List(){"UnityEngine.Light", "shadowAngle"},
new List(){"UnityEngine.Light", "shadowAngle"}

Unity3D:Xlua发布WebGL端注意事项

5.发布WebGL前要点编辑器窗口XLua > Generate Code生成一下脚本,不然发布会报错,每次修改Lua相关代码后都生成一下

6.如果要修改XLua所在目录,要同时修改一下Generator.cs中生成脚本的路径

Unity3D:Xlua发布WebGL端注意事项

7.如果XLua的Plugins/WebGL/xlua_webgl的所在目录被修改,要打开此脚本修改路径Unity3D: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"

         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Unity3D:Xlua发布WebGL端注意事项

最后:不要忘了发布WebGL前要点编辑器窗口XLua > Generate Code生成一下脚本,以上每一条都是我踩过的坑。


免责声明
本网站所收集的部分公开资料来源于AI生成和互联网,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复: 表情:
评论列表 (暂无评论,1238人围观)

还没有评论,来说两句吧...

目录[+]