调整 Event 和 Editor 命名空间
- 将原来的 CustomEvent 调整到 SepCore.Event - 将 Editor 文件夹下的统一到 SepCore.Editor,顺带修改了 Editor 程序集
This commit is contained in:
@@ -3,50 +3,56 @@ using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public class SceneSwitchLeft
|
||||
namespace SepCore.Editor
|
||||
{
|
||||
static SceneSwitchLeft()
|
||||
[InitializeOnLoad]
|
||||
public class SceneSwitchLeft
|
||||
{
|
||||
// 注册到全局工具栏绘制事件
|
||||
SceneView.duringSceneGui += OnSceneGUI;
|
||||
}
|
||||
|
||||
static void OnSceneGUI(SceneView sceneView)
|
||||
{
|
||||
// 在 Scene 视图的左上角绘制一个下拉菜单
|
||||
Handles.BeginGUI();
|
||||
|
||||
GUILayout.BeginArea(new Rect(10, 10, 200, 100));
|
||||
if (EditorGUILayout.DropdownButton(new GUIContent("快速切换场景"), FocusType.Passive, EditorStyles.toolbarDropDown))
|
||||
static SceneSwitchLeft()
|
||||
{
|
||||
ShowSceneMenu();
|
||||
// 注册到全局工具栏绘制事件
|
||||
SceneView.duringSceneGui += OnSceneGUI;
|
||||
}
|
||||
GUILayout.EndArea();
|
||||
|
||||
Handles.EndGUI();
|
||||
}
|
||||
|
||||
static void ShowSceneMenu()
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
|
||||
// 查找项目中所有启用(Enabled)的场景
|
||||
string[] sceneGuids = AssetDatabase.FindAssets("t:Scene");
|
||||
|
||||
foreach (string guid in sceneGuids)
|
||||
static void OnSceneGUI(SceneView sceneView)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
string name = Path.GetFileNameWithoutExtension(path);
|
||||
// 在 Scene 视图的左上角绘制一个下拉菜单
|
||||
Handles.BeginGUI();
|
||||
|
||||
menu.AddItem(new GUIContent(name), false, () => {
|
||||
if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||
GUILayout.BeginArea(new Rect(10, 10, 200, 100));
|
||||
if (EditorGUILayout.DropdownButton(new GUIContent("快速切换场景"), FocusType.Passive,
|
||||
EditorStyles.toolbarDropDown))
|
||||
{
|
||||
ShowSceneMenu();
|
||||
}
|
||||
|
||||
GUILayout.EndArea();
|
||||
|
||||
Handles.EndGUI();
|
||||
}
|
||||
|
||||
static void ShowSceneMenu()
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
|
||||
// 查找项目中所有启用(Enabled)的场景
|
||||
string[] sceneGuids = AssetDatabase.FindAssets("t:Scene");
|
||||
|
||||
foreach (string guid in sceneGuids)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
string name = Path.GetFileNameWithoutExtension(path);
|
||||
|
||||
menu.AddItem(new GUIContent(name), false, () =>
|
||||
{
|
||||
EditorSceneManager.OpenScene(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||
{
|
||||
EditorSceneManager.OpenScene(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
menu.ShowAsContext();
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user