From 70dcb03a3fb96134d5940baebf5081d31f512c63 Mon Sep 17 00:00:00 2001 From: ZemelLing <21308055+ZemelLing@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:09:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E4=BF=9DLauncher=E6=89=93=E5=BC=80?= =?UTF-8?q?=E7=9A=84main=E5=9C=BA=E6=99=AF=EF=BC=8C=E8=80=8C=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E5=85=B6=E4=BB=96=E5=90=8D=E7=A7=B0=E9=87=8C=E5=8C=85?= =?UTF-8?q?=E5=90=ABmain=E7=9A=84=E5=9C=BA=E6=99=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SceneSwitcher/Editor/SceneSwitcher.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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; }