Unity3D:Xlua发布WebGL端注意事项

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生成一下脚本,以上每一条都是我踩过的坑。

  • 8
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值