From d1270a55650fb006b0324789a87998585cca737a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E8=AF=AD?= Date: Thu, 24 Oct 2024 16:49:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=9C=BA=E6=99=AF=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/Tools/SceneEditor/SceneEditor.cs | 147 ++++---- .../Editor/Tools/SceneEditor/SceneEditor.uss | 5 - .../Tools/SceneEditor/SceneEditor.uss.meta | 11 - .../Editor/Tools/SceneEditor/SceneEditor.uxml | 8 - .../Tools/SceneEditor/SceneEditor.uxml.meta | 10 - .../Resources/ES3/ES3GlobalReferences.asset | 5 +- client/UserSettings/EditorUserSettings.asset | 10 +- client/UserSettings/Layouts/default-2022.dwlt | 320 ++++++++++-------- 8 files changed, 258 insertions(+), 258 deletions(-) delete mode 100644 client/Assets/Ether/Editor/Tools/SceneEditor/SceneEditor.uss delete mode 100644 client/Assets/Ether/Editor/Tools/SceneEditor/SceneEditor.uss.meta delete mode 100644 client/Assets/Ether/Editor/Tools/SceneEditor/SceneEditor.uxml delete mode 100644 client/Assets/Ether/Editor/Tools/SceneEditor/SceneEditor.uxml.meta 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