From fd0067c1ffe3bdc1f493dd2037577a2917a2ed54 Mon Sep 17 00:00:00 2001 From: Diego Franchini <49396838+Frank-99@users.noreply.github.com> Date: Sun, 2 Jun 2019 16:53:36 +0200 Subject: [PATCH 1/3] Update ToolbarExtender.cs --- Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs b/Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs index bcffcb0..f67c807 100644 --- a/Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs +++ b/Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs @@ -18,11 +18,16 @@ 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 From 8de4a3eb03582e21c3d543dad8211ad133c772dd Mon Sep 17 00:00:00 2001 From: Diego Franchini <49396838+Frank-99@users.noreply.github.com> Date: Sun, 2 Jun 2019 16:53:54 +0200 Subject: [PATCH 2/3] Update ToolbarExtender.cs --- Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs b/Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs index f67c807..6184f2c 100644 --- a/Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs +++ b/Assets/ToolbarExtender/Scripts/Editor/ToolbarExtender.cs @@ -18,11 +18,13 @@ public static class ToolbarExtender static ToolbarExtender() { Type toolbarType = typeof(Editor).Assembly.GetType("UnityEditor.Toolbar"); + #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); From d6f482882616075639615a6a5fe4ebe8b40259df Mon Sep 17 00:00:00 2001 From: Diego Franchini <49396838+Frank-99@users.noreply.github.com> Date: Sun, 2 Jun 2019 16:57:22 +0200 Subject: [PATCH 3/3] Update ToolbarCallback.cs --- Assets/ToolbarExtender/Scripts/Editor/ToolbarCallback.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Assets/ToolbarExtender/Scripts/Editor/ToolbarCallback.cs b/Assets/ToolbarExtender/Scripts/Editor/ToolbarCallback.cs index 66599c2..2dcbf2c 100644 --- a/Assets/ToolbarExtender/Scripts/Editor/ToolbarCallback.cs +++ b/Assets/ToolbarExtender/Scripts/Editor/ToolbarCallback.cs @@ -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 { @@ -58,4 +63,4 @@ static void OnGUI() if (handler != null) handler(); } } -} \ No newline at end of file +}