Skip to content

Commit

Permalink
Fix nullable params crashing invoke window
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Feb 14, 2024
1 parent 6edca28 commit c1cf718
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion RuntimeUnityEditor/Windows/Inspector/VariableFieldDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,19 @@ private static void DrawInvokeWindowFunc(int id)
{
var arg = _currentlyInvokingParamsValues[index];
var param = methodParams[index];
var obj = ClipboardWindow.TryGetObject(arg, out var clipboardObj) ? clipboardObj : Convert.ChangeType(arg, param.ParameterType);
var paramType = param.ParameterType;
var nullableParamType = Nullable.GetUnderlyingType(paramType);
if (nullableParamType != null)
{
if (string.IsNullOrEmpty(arg))
{
paramArgs[index] = null;
continue;
}
paramType = nullableParamType;
}

var obj = ClipboardWindow.TryGetObject(arg, out var clipboardObj) ? clipboardObj : Convert.ChangeType(arg, paramType);
paramArgs[index] = obj;
}
catch (Exception e)
Expand Down

0 comments on commit c1cf718

Please sign in to comment.