From c1cf718ae9bcd1ca5526639405987ae93cb84063 Mon Sep 17 00:00:00 2001 From: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:59:05 +0100 Subject: [PATCH] Fix nullable params crashing invoke window --- .../Windows/Inspector/VariableFieldDrawer.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/RuntimeUnityEditor/Windows/Inspector/VariableFieldDrawer.cs b/RuntimeUnityEditor/Windows/Inspector/VariableFieldDrawer.cs index c8fe20f..8865019 100644 --- a/RuntimeUnityEditor/Windows/Inspector/VariableFieldDrawer.cs +++ b/RuntimeUnityEditor/Windows/Inspector/VariableFieldDrawer.cs @@ -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)