Skip to content

Commit 3fcbb1b

Browse files
committed
处理值类型默认值是default的情况
1 parent d60c8a1 commit 3fcbb1b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

unity/Assets/core/upm/Runtime/Src/PInvoke/Wrapper/ExpressionsWrap.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,8 @@ private static Expression scriptToNative(CompileContext context, ParameterInfo p
851851
var res = scriptToNative(context, parameterInfo.ParameterType, value);
852852
if (parameterInfo.HasDefaultValue)
853853
{
854-
return Expression.Condition(callPApi(context.Apis, "is_undefined", context.Env, value), Expression.Constant(parameterInfo.DefaultValue, parameterInfo.ParameterType), res);
854+
return Expression.Condition(callPApi(context.Apis, "is_undefined", context.Env, value),
855+
parameterInfo.DefaultValue == null && parameterInfo.ParameterType.IsValueType ? Expression.Default(parameterInfo.ParameterType) : Expression.Constant(parameterInfo.DefaultValue, parameterInfo.ParameterType), res);
855856
}
856857
else
857858
{

0 commit comments

Comments
 (0)