[+] ToolbarExt

[+] ToolbarExt
This commit is contained in:
ALEXTANG
2023-05-12 10:56:45 +08:00
parent 0ce268aaf6
commit 73b3ae6527
16 changed files with 90 additions and 1 deletions

View File

@@ -0,0 +1,85 @@
using UnityEditor;
using UnityEngine;
using UnityToolbarExtender;
namespace TEngine
{
[InitializeOnLoad]
public class EditorResourceMode
{
static class ToolbarStyles
{
public static readonly GUIStyle ToolBarExtenderBtnStyle;
public static readonly GUIStyle ToolBarTextStyle;
public static readonly GUIStyle ToolBarButtonGuiStyle;
static ToolbarStyles()
{
ToolBarExtenderBtnStyle = new GUIStyle("Command")
{
fontSize = 12,
alignment = TextAnchor.MiddleCenter,
imagePosition = ImagePosition.ImageAbove,
fontStyle = FontStyle.Normal,
fixedWidth = 60
};
ToolBarTextStyle = new GUIStyle(ButtonStyleName)
{
padding = new RectOffset(2, 8, 2, 2),
alignment = TextAnchor.MiddleCenter,
fontStyle = FontStyle.Bold
};
ToolBarButtonGuiStyle = new GUIStyle(ButtonStyleName)
{
padding = new RectOffset(2, 8, 2, 2),
alignment = TextAnchor.MiddleCenter,
fontStyle = FontStyle.Bold
};
}
}
static EditorResourceMode()
{
ToolbarExtender.RightToolbarGUI.Add(OnToolbarGUI);
_resourceModeIndex = EditorPrefs.GetInt("EditorResourceMode",0);
}
static readonly string ButtonStyleName = "Tab middle";
static GUIStyle _buttonGuiStyle;
private static readonly string[] ResourceModeNames = { "EditorMode (编辑器下的模拟模式)", "OfflinePlayMode (单机模式)", "HostPlayMode (联机运行模式)" };
private static int _resourceModeIndex = 0;
public static int ResourceModeIndex => _resourceModeIndex;
static void OnToolbarGUI()
{
EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
{
// GUILayout.Label("资源加载模式:",ToolbarStyles.ToolBarTextStyle);
GUILayout.Space(2);
GUILayout.Label("");
GUILayout.FlexibleSpace();
// 资源模式
int selectedIndex = EditorGUILayout.Popup("", _resourceModeIndex, ResourceModeNames,ToolbarStyles.ToolBarButtonGuiStyle);
// ReSharper disable once RedundantCheckBeforeAssignment
if (selectedIndex != _resourceModeIndex)
{
Debug.Log($"更改编辑器资源运行模式 : {ResourceModeNames[selectedIndex]}");
_resourceModeIndex = selectedIndex;
EditorPrefs.SetInt("EditorResourceMode",selectedIndex);
}
GUILayout.FlexibleSpace();
GUILayout.Space(400);
}
EditorGUI.EndDisabledGroup();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ab26dd2998d84a08b35c0132e1814199
timeCreated: 1683857308

View File

@@ -1,8 +1,9 @@
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityToolbarExtender;
namespace UnityToolbarExtender
namespace TEngine
{
[InitializeOnLoad]
public class SceneSwitchLeftButton