Skip to content

Commit 9f4c9ba

Browse files
authored
Merge pull request #12 from Frank-99/master
2019 final fix
2 parents b22b0be + d6f4828 commit 9f4c9ba

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Assets/ToolbarExtender/Scripts/Editor/ToolbarCallback.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
using UnityEngine;
33
using UnityEditor;
44
using System.Reflection;
5+
6+
#if UNITY_2019_1_OR_NEWER
7+
using UnityEngine.UIElements;
8+
#else
59
using UnityEngine.Experimental.UIElements;
10+
#endif
611

712
namespace UnityToolbarExtender
813
{
@@ -58,4 +63,4 @@ static void OnGUI()
5863
if (handler != null) handler();
5964
}
6065
}
61-
}
66+
}

Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@ public static class ToolbarExtender
1818
static ToolbarExtender()
1919
{
2020
Type toolbarType = typeof(Editor).Assembly.GetType("UnityEditor.Toolbar");
21-
FieldInfo toolIcons = toolbarType.GetField("s_ShownToolIcons",
21+
22+
#if UNITY_2019_1_OR_NEWER
23+
string fieldName = "k_ToolCount";
24+
#else
25+
string fieldName = "s_ShownToolIcons";
26+
#endif
27+
28+
FieldInfo toolIcons = toolbarType.GetField(fieldName,
2229
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
2330

2431
#if UNITY_2019_1_OR_NEWER
25-
m_toolCount = 7;
32+
m_toolCount = toolIcons != null ? ((int) toolIcons.GetValue(null)) : 7;
2633
#elif UNITY_2018_1_OR_NEWER
2734
m_toolCount = toolIcons != null ? ((Array) toolIcons.GetValue(null)).Length : 6;
2835
#else

0 commit comments

Comments
 (0)