hellbound/Assets/Scripts/Core/Editor/CheatsButton.cs

43 lines
1.1 KiB
C#
Raw Normal View History

2021-11-26 11:16:25 +03:00
using UnityEditor;
using UnityEngine;
using UnityToolbarExtender;
[InitializeOnLoad]
public static class CheatsButton
{
static CheatsButton()
{
ToolbarExtender.RightToolbarGUI.Add(OnToolbarGUI);
}
private static void OnToolbarGUI()
{
var tex = EditorGUIUtility.IconContent(@"WelcomeScreen.AssetStoreLogo").image;
const string tip = "Open cheats window";
if (GUILayout.Button(new GUIContent(null, tex, tip), ToolbarStyles.CommandButtonStyle))
{
if(CheatsWindow.IsVisible)
CheatsWindow.Close();
else
CheatsWindow.Open();
}
}
private static class ToolbarStyles
{
public static readonly GUIStyle CommandButtonStyle;
static ToolbarStyles()
{
CommandButtonStyle = new GUIStyle("Command")
{
fontSize = 16,
alignment = TextAnchor.MiddleCenter,
imagePosition = ImagePosition.ImageAbove,
fontStyle = FontStyle.Bold
};
}
}
}