1.在Project窗口搜索ExampleConfig
2.打开后Ctrl+F搜索UNITY_2018_1_OR_NEWER
3.在其中加一段代码,忽略掉Span<>和ReadOnlySpan<>,并保存
[BlackList]
public static List<Type> BlackGenericTypeList = new List<Type>()
{
typeof(Span<>),
typeof(ReadOnlySpan<>)
};
private static bool IsBlacklistedGenericType(Type type)
{
if (!type.IsGenericType) return false;
return BlackGenericTypeList.Contains(type.GetGenericTypeDefinition());
}
[BlackList]
public static Func<MemberInfo, bool> GenericTypeFilter = (memberInfo) =>
{
switch (memberInfo)
{
case PropertyInfo propertyInfo:
return IsBlacklistedGenericType(propertyInfo.PropertyType);
case ConstructorInfo constructorInfo:
return constructorInfo.GetParameters().Any(p => IsBlacklistedGenericType(p.ParameterType));
case MethodInfo methodInfo:
return methodInfo.GetParameters().Any(p => IsBlacklistedGenericType(p.ParameterType));
default:
return false;
}
};
4.清除后在重新生成即可
相关链接:ToLua中的解决方法Unity中ToLua The type ReadOnlySpan<> & Span<> may not be used as a type argument 解决方法-CSDN博客