Skip to content

Commit 30ae37c

Browse files
author
Lucas Pereira Vasconcelos
committed
Fixed positioning on new Unity theme
1 parent 49bb2cb commit 30ae37c

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Editor/ToolbarExtender.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ static ToolbarExtender()
2828
FieldInfo toolIcons = toolbarType.GetField(fieldName,
2929
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
3030

31-
#if UNITY_2019_1_OR_NEWER
31+
#if UNITY_2019_3_OR_NEWER
32+
m_toolCount = toolIcons != null ? ((int) toolIcons.GetValue(null)) : 8;
33+
#elif UNITY_2019_1_OR_NEWER
3234
m_toolCount = toolIcons != null ? ((int) toolIcons.GetValue(null)) : 7;
3335
#elif UNITY_2018_1_OR_NEWER
3436
m_toolCount = toolIcons != null ? ((Array) toolIcons.GetValue(null)).Length : 6;
@@ -40,7 +42,11 @@ static ToolbarExtender()
4042
ToolbarCallback.OnToolbarGUI += OnGUI;
4143
}
4244

45+
#if UNITY_2019_3_OR_NEWER
46+
public const float space = 8;
47+
#else
4348
public const float space = 10;
49+
#endif
4450
public const float largeSpace = 20;
4551
public const float buttonWidth = 32;
4652
public const float dropdownWidth = 80;
@@ -68,7 +74,11 @@ static void OnGUI()
6874
Rect leftRect = new Rect(0, 0, screenWidth, Screen.height);
6975
leftRect.xMin += space; // Spacing left
7076
leftRect.xMin += buttonWidth * m_toolCount; // Tool buttons
77+
#if UNITY_2019_3_OR_NEWER
78+
leftRect.xMin += space; // Spacing between tools and pivot
79+
#else
7180
leftRect.xMin += largeSpace; // Spacing between tools and pivot
81+
#endif
7282
leftRect.xMin += 64 * 2; // Pivot buttons
7383
leftRect.xMax = playButtonsPosition;
7484

@@ -80,7 +90,11 @@ static void OnGUI()
8090
rightRect.xMax -= dropdownWidth; // Layout
8191
rightRect.xMax -= space; // Spacing between layout and layers
8292
rightRect.xMax -= dropdownWidth; // Layers
93+
#if UNITY_2019_3_OR_NEWER
94+
rightRect.xMax -= space; // Spacing between layers and account
95+
#else
8396
rightRect.xMax -= largeSpace; // Spacing between layers and account
97+
#endif
8498
rightRect.xMax -= dropdownWidth; // Account
8599
rightRect.xMax -= space; // Spacing between account and cloud
86100
rightRect.xMax -= buttonWidth; // Cloud
@@ -94,10 +108,17 @@ static void OnGUI()
94108
rightRect.xMax -= space;
95109

96110
// Add top and bottom margins
111+
#if UNITY_2019_3_OR_NEWER
112+
leftRect.y = 4;
113+
leftRect.height = 22;
114+
rightRect.y = 4;
115+
rightRect.height = 22;
116+
#else
97117
leftRect.y = 5;
98118
leftRect.height = 24;
99119
rightRect.y = 5;
100120
rightRect.height = 24;
121+
#endif
101122

102123
if (leftRect.width > 0)
103124
{

0 commit comments

Comments
 (0)