mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
[+] ToolbarExt
[+] ToolbarExt
This commit is contained in:
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ab26dd2998d84a08b35c0132e1814199
|
||||||
|
timeCreated: 1683857308
|
@@ -1,8 +1,9 @@
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.SceneManagement;
|
using UnityEditor.SceneManagement;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityToolbarExtender;
|
||||||
|
|
||||||
namespace UnityToolbarExtender
|
namespace TEngine
|
||||||
{
|
{
|
||||||
[InitializeOnLoad]
|
[InitializeOnLoad]
|
||||||
public class SceneSwitchLeftButton
|
public class SceneSwitchLeftButton
|
Reference in New Issue
Block a user