Skip to content

Commit a44ae9b

Browse files
committed
Improved examples
1 parent d89e01d commit a44ae9b

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

Assets/ToolbarExtender/Example/Scripts/Editor/SceneSwitcher.cs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ namespace UnityToolbarExtender.Examples
66
{
77
static class ToolbarStyles
88
{
9-
public static GUIStyle commandButtonStyle;
10-
public static GUIStyle appToolbar;
9+
public static readonly GUIStyle commandButtonStyle;
1110

1211
static ToolbarStyles()
1312
{
14-
commandButtonStyle = new GUIStyle("Command");
15-
commandButtonStyle.fontSize = 16;
16-
commandButtonStyle.alignment = TextAnchor.MiddleCenter;
17-
commandButtonStyle.imagePosition = ImagePosition.ImageAbove;
18-
commandButtonStyle.fontStyle = FontStyle.Bold;
13+
commandButtonStyle = new GUIStyle("Command")
14+
{
15+
fontSize = 16,
16+
alignment = TextAnchor.MiddleCenter,
17+
imagePosition = ImagePosition.ImageAbove,
18+
fontStyle = FontStyle.Bold
19+
};
1920
}
2021
}
2122

@@ -30,28 +31,16 @@ static SceneSwitchLeftButton()
3031
static void OnToolbarGUI()
3132
{
3233
GUILayout.FlexibleSpace();
33-
if(GUILayout.Button("1", ToolbarStyles.commandButtonStyle))
34+
35+
if(GUILayout.Button(new GUIContent("1", "Start Scene 1"), ToolbarStyles.commandButtonStyle))
3436
{
3537
SceneHelper.StartScene("Assets/ToolbarExtender/Example/Scenes/Scene1.unity");
3638
}
37-
}
38-
}
39-
40-
[InitializeOnLoad]
41-
public class SceneSwitchRightButton
42-
{
43-
static SceneSwitchRightButton()
44-
{
45-
ToolbarExtender.RightToolbarGUI.Add(OnToolbarGUI);
46-
}
4739

48-
static void OnToolbarGUI()
49-
{
50-
if(GUILayout.Button("2", ToolbarStyles.commandButtonStyle))
40+
if(GUILayout.Button(new GUIContent("2", "Start Scene 2"), ToolbarStyles.commandButtonStyle))
5141
{
5242
SceneHelper.StartScene("Assets/ToolbarExtender/Example/Scenes/Scene2.unity");
5343
}
54-
GUILayout.FlexibleSpace();
5544
}
5645
}
5746

Assets/ToolbarExtender/Example/Scripts/Editor/SceneViewFocuser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void OnPlayModeChanged(PlayModeStateChange obj)
4646

4747
static void OnToolbarGUI()
4848
{
49-
var tex = (Texture) EditorGUIUtility.Load(@"UnityEditor.SceneView");
49+
var tex = EditorGUIUtility.IconContent(@"UnityEditor.SceneView").image;
5050

5151
GUI.changed = false;
5252

0 commit comments

Comments
 (0)