Tencent / xLua

xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.
Other
9.37k stars 2.46k forks source link

Generate code导致Unity闪退 #631

Open wumohai opened 5 years ago

wumohai commented 5 years ago

Unity2018.4.7f1 在Xlua Generate code导致Unity闪退。在Script Runtime Version选择.net4的时候会闪退,3.5就正常。

chexiongsheng commented 5 years ago

你拷贝了一份MonoBleedingEdge到Tools了?

wumohai commented 5 years ago

没有的。

chexiongsheng commented 5 years ago

没怎么听说这问题。 我自己也在2018上生成也没问题。 所以估计可能和你的带生成代码中含有比较特殊的类有关。你先用排除法查下哪个类导致的?

wumohai commented 5 years ago

我断点过。是我在配置HotfixCfg里面 。这里面判断是不是编辑器相关代码。断到过BetterList,一直递归调用,最后导致Unity崩溃。BetterList是NGUI引入的数据结构。Script Runtime Version选择.net4的时候会闪退,3.5就正常。 static bool typeHasEditorRef(Type type) { if (type.Namespace != null && (type.Namespace == "UnityEditor" || type.Namespace.StartsWith("UnityEditor."))) { return true; } if (type.IsNested) { return typeHasEditorRef(type.DeclaringType); } if (type.IsByRef || type.IsArray) { return typeHasEditorRef(type.GetElementType()); } if (type.IsGenericType) { foreach (var typeArg in type.GetGenericArguments()) { if (typeHasEditorRef(typeArg)) { return true; } } } return false; }

chexiongsheng commented 5 years ago

好像也不会闪退。 typeHasEditorRef只会对delegate调用,我特意对UIWidget.OnPostFillCallback调用了delegateHasEditorRef,没事