diff --git a/UnityProject/Assets/TEngine/Editor/ToolbarExtender/Custom/SceneSwitcher/Editor/SceneSwitcher.cs b/UnityProject/Assets/TEngine/Editor/ToolbarExtender/Custom/SceneSwitcher/Editor/SceneSwitcher.cs index 9da46f7b..3aa688f0 100644 --- a/UnityProject/Assets/TEngine/Editor/ToolbarExtender/Custom/SceneSwitcher/Editor/SceneSwitcher.cs +++ b/UnityProject/Assets/TEngine/Editor/ToolbarExtender/Custom/SceneSwitcher/Editor/SceneSwitcher.cs @@ -72,7 +72,23 @@ namespace TEngine } else { - string scenePath = AssetDatabase.GUIDToAssetPath(guids[0]); + string scenePath = null; + // 优先打开完全匹配_sceneToOpen的场景 + for (var i = 0; i < guids.Length; i++) + { + scenePath = AssetDatabase.GUIDToAssetPath(guids[i]); + if (scenePath.EndsWith("/" + _sceneToOpen + ".unity")) + { + break; + } + } + + // 如果没有完全匹配的场景,默认显示找到的第一个场景 + if (string.IsNullOrEmpty(scenePath)) + { + scenePath = AssetDatabase.GUIDToAssetPath(guids[0]); + } + EditorSceneManager.OpenScene(scenePath); EditorApplication.isPlaying = true; }