Unity3D:Xlua发布WebGL端注意事项

06-01 1151阅读

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进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们。

相关阅读

目录[+]

取消
微信二维码
微信二维码
支付宝二维码