您的位置:首页 > 移动开发 > Unity3D

Unity3D + ulua simpleframework的问题汇总

2016-02-14 14:30 519 查看
使用最新版本的(此时最新)的ulua, 生成wrapper文件时,对范型支持支持不是很好,如:

{System.Collections.Generic.List`1[System.String]&} 的type类型,会生成出System.Collections.Generic.List`1[System.String]到c#中,导致编译不通过。

经过代码review, 发现ToLuaExport文件中的GetStrType,对上面的类型判断IsGenericType返回false, 不确定是否是什么原因(&)引起的,

所以在else中修改成如下代码,就可以生成List<String>

else if(t.IsGenericType)
{
return GetGenericName(t);
}
else
{
// modified by cpeng for il2cpp
// referenced to BindLua::GetGenericName
<span style="font-family: Menlo;">				Debug.Log("IsGenericType not work for " + t.ToString());</span>
// t.IsGenericType for {System.Collections.Generic.List`1[System.String]&} somehow return false, we handle it here.
if (t.GetGenericArguments().Length != 0) {
Type[] gArgs = t.GetGenericArguments();
string typeName = t.Name;
string pureTypeName = typeName.Substring(0, typeName.IndexOf('`'));

return pureTypeName + "<" + string.Join(",", GetGenericName(gArgs)) + ">";
}
return _C(t.ToString());
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: