Skip to content

Commit

Permalink
Fix get items cast is invalid in 2021.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chikacc committed Oct 9, 2021
1 parent 0b0c6cb commit b5a46f0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Base/Utils/GenericMenuUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ internal class GenericMenuUtil
private static readonly FieldInfo menuItemFunc = menuItemType.GetField("func", BindingFlags.Public | BindingFlags.Instance);
private static readonly FieldInfo menuItemFunc2 = menuItemType.GetField("func2", BindingFlags.Public | BindingFlags.Instance);

#if UNITY_2021_1_OR_NEWER
public static IList GetItems(GenericMenu menu)
{
return (IList)menuItemsField.GetValue(menu);
}
#else
public static ArrayList GetItems(GenericMenu menu)
{
return (ArrayList)menuItemsField.GetValue(menu);
}
#endif

public static GUIContent GetContent(object menuItem)
{
Expand Down

0 comments on commit b5a46f0

Please sign in to comment.