Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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