diff --git a/client/Assets/Ether/Editor/Tools/SceneEditor/SceneEditor.cs b/client/Assets/Ether/Editor/Tools/SceneEditor/SceneEditor.cs index c074308..8a7abca 100644 --- a/client/Assets/Ether/Editor/Tools/SceneEditor/SceneEditor.cs +++ b/client/Assets/Ether/Editor/Tools/SceneEditor/SceneEditor.cs @@ -1,6 +1,9 @@  using Ether; +using Sirenix.OdinInspector; +using Sirenix.OdinInspector.Editor; using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -8,74 +11,85 @@ using UnityEditor; using UnityEditor.SceneManagement; using UnityEditor.ShortcutManagement; using UnityEngine; -using UnityEngine.UIElements; -public class SceneEditor : EditorWindow +public class SceneEditor : OdinEditorWindow { - [SerializeField] - private VisualTreeAsset m_VisualTreeAsset = default; - - [SerializeField] - private StyleSheet styleSheet = default; - - static SceneEditor instance; [MenuItem("工具/场景/场景设置")] [Shortcut("场景设置", KeyCode.F6)] - public static void ShowExample() + private static void OpenWindow() { - if (instance == null) + var window = GetWindow(); + window.titleContent = new GUIContent("场景设置"); + window.Show(); + } + + protected override void OnEnable() + { + bootScenePath = JumpSceneEditor.SceneExists("Boot"); + SetDropdown(); + } + + Dictionary sceneDic = new Dictionary(); + + private static string bootScenePath; + private string bootBtnName = "运行游戏"; + + [Button("$bootBtnName", ButtonSizes.Large), PropertyOrder(3)] + public void BootBtnAction() + { + JumpSceneEditor.JumpBootScene(); + } + + [ValueDropdown("dropDownSceneList"), PropertyOrder(1), LabelText("选择场景")] + public string selectSceneName; + + [Button("跳转场景", ButtonSizes.Large), PropertyOrder(2)] + public void JumpSceneAction() + { + if (string.IsNullOrEmpty(selectSceneName)) { - instance = GetWindow(); - instance.titleContent = new GUIContent("场景设置"); + return; } - else + + string scenePath = sceneDic[selectSceneName]; + + SceneAsset asset = AssetDatabase.LoadAssetAtPath(scenePath); + + EditorUtility.FocusProjectWindow(); + EditorGUIUtility.PingObject(asset); + Selection.activeObject = asset; + + if (EditorSceneManager.GetActiveScene().path != scenePath) { - instance.Close(); - instance = null; + EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single); } } - VisualElement root; + private List dropDownSceneList = new List(); - string bootScenePath; - Button bootBtn; - DropdownField cutSceneDropDown; - Dictionary sceneDic = new Dictionary(); - - public void CreateGUI() + private void Update() { - root = rootVisualElement; - - m_VisualTreeAsset.CloneTree(root); - root.styleSheets.Add(styleSheet); - - bootScenePath = JumpSceneEditor.SceneExists("Boot"); - - bootBtn = root.Q("Root").Q