Unity3D:Xlua发布WebGL端注意事项

作者 : admin 本文共2302个字,预计阅读时间需要6分钟 发布时间: 2024-06-17 共1人阅读

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端注意事项插图(1)

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

Unity3D:Xlua发布WebGL端注意事项插图(2)

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

Unity3D:Xlua发布WebGL端注意事项插图(3)

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

Unity3D:Xlua发布WebGL端注意事项插图(4)

%后面加空格如下

Unity3D:Xlua发布WebGL端注意事项插图(5)

报错解决!

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端注意事项插图(6)

解决办法: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端注意事项插图(7)

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

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

Unity3D:Xlua发布WebGL端注意事项插图(8)

7.如果XLua的Plugins/WebGL/xlua_webgl的所在目录被修改,要打开此脚本修改路径Unity3D:Xlua发布WebGL端注意事项插图(9)

不然会报错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端注意事项插图(10)

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

本站无任何商业行为
个人在线分享 » Unity3D:Xlua发布WebGL端注意事项
E-->