Skip to content

Commit

Permalink
Fix handling the HasNativeTypeDrawer method for Unity 2022.3.23
Browse files Browse the repository at this point in the history
  • Loading branch information
arimger committed Apr 5, 2024
1 parent 2e2611b commit eaafc48
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions Assets/Editor Toolbox/Editor/ToolboxDrawerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ internal static void InitializeModule()
ToolboxEditorHandler.OnEditorReload += ReloadDrawers;
}


private static readonly Type decoratorDrawerBase = typeof(ToolboxDecoratorDrawer<>);
private static readonly Type conditionDrawerBase = typeof(ToolboxConditionDrawer<>);
private static readonly Type selfPropertyDrawerBase = typeof(ToolboxSelfPropertyDrawer<>);
Expand Down Expand Up @@ -261,11 +260,25 @@ internal static void UpdateDrawers(IToolboxInspectorSettings settings)
/// </summary>
internal static bool HasNativeTypeDrawer(Type type)
{
#if UNITY_2023_3_OR_NEWER
var parameters = new object[] { type, null, false };
#else
var parameters = new object[] { type };
#endif
object[] parameters;
var parameterInfos = getDrawerTypeForTypeMethod.GetParameters();
var parametersCount = parameterInfos.Length;
switch (parametersCount)
{
default:
case 1:
parameters = new object[] { type };
break;
//NOTE: Unity 2022.3.23 or above
case 2:
parameters = new object[] { type, false };
break;
//NOTE: Unity 2023.3.x or above
case 3:
parameters = new object[] { type, null, false };
break;
}

var result = getDrawerTypeForTypeMethod.Invoke(null, parameters) as Type;
return result != null && typeof(PropertyDrawer).IsAssignableFrom(result);
}
Expand Down

0 comments on commit eaafc48

Please sign in to comment.