File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Assets/ToolbarExtender/Scripts/Editor Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 22using UnityEngine ;
33using UnityEditor ;
44using System . Reflection ;
5+
6+ #if UNITY_2019_1_OR_NEWER
7+ using UnityEngine . UIElements ;
8+ #else
59using UnityEngine . Experimental . UIElements ;
10+ #endif
611
712namespace UnityToolbarExtender
813{
@@ -58,4 +63,4 @@ static void OnGUI()
5863 if ( handler != null ) handler ( ) ;
5964 }
6065 }
61- }
66+ }
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments