Skip to content

Commit

Permalink
Merge pull request #12 from Frank-99/master
Browse files Browse the repository at this point in the history
2019 final fix
  • Loading branch information
marijnz authored Jun 2, 2019
2 parents b22b0be + d6f4828 commit 9f4c9ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Assets/ToolbarExtender/Scripts/Editor/ToolbarCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
using UnityEngine;
using UnityEditor;
using System.Reflection;

#if UNITY_2019_1_OR_NEWER
using UnityEngine.UIElements;
#else
using UnityEngine.Experimental.UIElements;
#endif

namespace UnityToolbarExtender
{
Expand Down Expand Up @@ -58,4 +63,4 @@ static void OnGUI()
if (handler != null) handler();
}
}
}
}
11 changes: 9 additions & 2 deletions Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@ public static class ToolbarExtender
static ToolbarExtender()
{
Type toolbarType = typeof(Editor).Assembly.GetType("UnityEditor.Toolbar");
FieldInfo toolIcons = toolbarType.GetField("s_ShownToolIcons",

#if UNITY_2019_1_OR_NEWER
string fieldName = "k_ToolCount";
#else
string fieldName = "s_ShownToolIcons";
#endif

FieldInfo toolIcons = toolbarType.GetField(fieldName,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);

#if UNITY_2019_1_OR_NEWER
m_toolCount = 7;
m_toolCount = toolIcons != null ? ((int) toolIcons.GetValue(null)) : 7;
#elif UNITY_2018_1_OR_NEWER
m_toolCount = toolIcons != null ? ((Array) toolIcons.GetValue(null)).Length : 6;
#else
Expand Down

0 comments on commit 9f4c9ba

Please sign in to comment.