Skip to content

Commit eaafc48

Browse files
committed
Fix handling the HasNativeTypeDrawer method for Unity 2022.3.23
1 parent 2e2611b commit eaafc48

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

Assets/Editor Toolbox/Editor/ToolboxDrawerModule.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ internal static void InitializeModule()
2323
ToolboxEditorHandler.OnEditorReload += ReloadDrawers;
2424
}
2525

26-
2726
private static readonly Type decoratorDrawerBase = typeof(ToolboxDecoratorDrawer<>);
2827
private static readonly Type conditionDrawerBase = typeof(ToolboxConditionDrawer<>);
2928
private static readonly Type selfPropertyDrawerBase = typeof(ToolboxSelfPropertyDrawer<>);
@@ -261,11 +260,25 @@ internal static void UpdateDrawers(IToolboxInspectorSettings settings)
261260
/// </summary>
262261
internal static bool HasNativeTypeDrawer(Type type)
263262
{
264-
#if UNITY_2023_3_OR_NEWER
265-
var parameters = new object[] { type, null, false };
266-
#else
267-
var parameters = new object[] { type };
268-
#endif
263+
object[] parameters;
264+
var parameterInfos = getDrawerTypeForTypeMethod.GetParameters();
265+
var parametersCount = parameterInfos.Length;
266+
switch (parametersCount)
267+
{
268+
default:
269+
case 1:
270+
parameters = new object[] { type };
271+
break;
272+
//NOTE: Unity 2022.3.23 or above
273+
case 2:
274+
parameters = new object[] { type, false };
275+
break;
276+
//NOTE: Unity 2023.3.x or above
277+
case 3:
278+
parameters = new object[] { type, null, false };
279+
break;
280+
}
281+
269282
var result = getDrawerTypeForTypeMethod.Invoke(null, parameters) as Type;
270283
return result != null && typeof(PropertyDrawer).IsAssignableFrom(result);
271284
}

0 commit comments

Comments
 (0)