slua icon indicating copy to clipboard operation
slua copied to clipboard

SLua导出错误

Open hanyq opened this issue 5 years ago • 1 comments

Unity2019.2导出集合相关接口时编译报错。 看导出的源码,是SLua多导出了几个方法。 比如Dictionary,多了两个个构造方法,其中一个参数是 IEnumerable<System.Collections.Generic.KeyValuePair<System.Int32,System.String>>;

多导出一个方法:public bool Remove (TKey key, out TValue value);

hanyq avatar Jan 07 '20 05:01 hanyq

这是因为Unity运行时和编译时加载的dll不同导致的。

问题会出现在当Scripting Runtime Version选择.Net 4.x时(Unity 2019.2.6中这项设置貌似移除了),如下图:

image

运行时

Unity运行时加载的dll是Unity安装路径\Editor\Data\MonoBleedingEdge\lib\mono\unityjit\mscorlib.dll 如下图:

image

编译时

Unity编译时加载的dll是Unity安装路径\Editor\Data\MonoBleedingEdge\lib\mono\4.7.1-api\mscorlib.dll 如下图:

image

解决方法

  1. Scripting Runtime Version选择.Net 3.5(需要评估对项目的影响)
  2. 导出时添加黑名单过滤掉报错的方法。

GrandZhuo avatar Mar 24 '20 12:03 GrandZhuo