From 76c16dec76fc2c90c4c9dccce04ff68d52d34a90 Mon Sep 17 00:00:00 2001 From: stary <834207172@qq.COM> Date: Thu, 16 Apr 2026 23:59:56 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90m=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChangePlayerMode/ChangePlayerMode.cs | 83 +++---------------- Assets/00.StaryEvoTools/package.json | 2 +- 2 files changed, 13 insertions(+), 72 deletions(-) diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePlayerMode.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePlayerMode.cs index 441bf31..f1fbb49 100644 --- a/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePlayerMode.cs +++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePlayerMode.cs @@ -19,8 +19,7 @@ namespace Stary.Evo.Editor private const string EditorSimulateMode = "Evo/Schema/ChangePlayer/EditorSimulateMode(编辑器调试模式)"; private const string HostPlayMode = "Evo/Schema/ChangePlayer/HostPlayMode(联机运行模式)"; private const string LocalPlayMode = "Evo/Schema/ChangePlayer/LocalPlayMode(本地运行模式)"; - private const string WebPlayMode = "Evo/Schema/ChangePlayer/WebPlayMode(Web运行模式)"; - + // Web 子模式菜单路径(作为 WebPlayMode 的子菜单) private const string WebNormalSubMode = "Evo/Schema/ChangePlayer/WebPlayMode(Web运行模式)/WebGL 普通模式"; private const string WechatMiniSubMode = "Evo/Schema/ChangePlayer/WebPlayMode(Web运行模式)/微信小程序模式"; @@ -36,52 +35,32 @@ namespace Stary.Evo.Editor [MenuItem(LocalPlayMode, false, 3)] private static void SetLocalMode() => SetPlayerMode(PLayerMode.LOCAL_PLAYMODE); - - + [MenuItem(WebNormalSubMode, false, 3)] + private static void SetWebMode() => SetPlayerMode(PLayerMode.WEB_NORMAL); + [MenuItem(WechatMiniSubMode, false, 3)] + private static void SetWechatMiniMode() => SetPlayerMode(PLayerMode.WECHAT_MINIGAME); #endregion - #region Web 子模式菜单 - [MenuItem(WebNormalSubMode, false, 4)] - private static void SetWebNormalMode() => SetWebSubMode(WebSubMode.WEB_NORMAL); - - [MenuItem(WechatMiniSubMode, false, 4)] - private static void SetWechatMiniMode() => SetWebSubMode(WebSubMode.WECHAT_MINIGAME); - - #endregion #region 菜单验证 [MenuItem(EditorSimulateMode, true, 3)] [MenuItem(HostPlayMode, true, 3)] [MenuItem(LocalPlayMode, true, 3)] + [MenuItem(WebNormalSubMode, true, 1)] + [MenuItem(WechatMiniSubMode, true, 2)] private static bool ValidateMainModeMenu() { string platform = CustomEditorPrefs.GetString("ChangePlayerSchema"); Menu.SetChecked(EditorSimulateMode, platform == PLayerMode.EDITOR_SIMULATEMODE.ToString()); Menu.SetChecked(HostPlayMode, platform == PLayerMode.HOST_PLAYMODE.ToString()); Menu.SetChecked(LocalPlayMode, platform == PLayerMode.LOCAL_PLAYMODE.ToString()); + Menu.SetChecked(WebNormalSubMode, platform == PLayerMode.WEB_NORMAL.ToString()); + Menu.SetChecked(WechatMiniSubMode, platform == PLayerMode.WECHAT_MINIGAME.ToString()); return true; } - - [MenuItem(WebNormalSubMode, false)] - private static bool ValidateWebNormalMenu() - { - // 只在 WebPlayMode 下启用子菜单 - bool isWebMode = _pLayerMode == PLayerMode.WEB_PLAYMODE; - string subMode = CustomEditorPrefs.GetString("WebSubMode", WebSubMode.WEB_NORMAL.ToString()); - Menu.SetChecked(WebNormalSubMode, subMode == WebSubMode.WEB_NORMAL.ToString()); - return isWebMode; - } - - [MenuItem(WechatMiniSubMode, false)] - private static bool ValidateWechatMiniMenu() - { - bool isWebMode = _pLayerMode == PLayerMode.WEB_PLAYMODE; - string subMode = CustomEditorPrefs.GetString("WebSubMode", WebSubMode.WEB_NORMAL.ToString()); - Menu.SetChecked(WechatMiniSubMode, subMode == WebSubMode.WECHAT_MINIGAME.ToString()); - return isWebMode; - } + #endregion @@ -95,7 +74,6 @@ namespace Stary.Evo.Editor .Split(';') .Where(d => !string.IsNullOrEmpty(d)) .Where(d => !Enum.GetNames(typeof(PLayerMode)).Contains(d)) - .Where(d => !Enum.GetNames(typeof(WebSubMode)).Contains(d)) .ToList(); // 添加新模式 @@ -103,42 +81,11 @@ namespace Stary.Evo.Editor _pLayerMode = mode; CustomEditorPrefs.SetString("ChangePlayerSchema", _pLayerMode.ToString()); - - // 如果切换到 Web 模式,恢复之前保存的子模式或默认使用普通模式 - if (mode == PLayerMode.WEB_PLAYMODE) - { - string savedSubMode = CustomEditorPrefs.GetString("WebSubMode", WebSubMode.WEB_NORMAL.ToString()); - defines.Add(savedSubMode); - } - + ApplyDefines(defines); Debug.Log($"[ChangePlayerSchema] 切换至主模式: {mode}"); } - - public static void SetWebSubMode(WebSubMode subMode) - { - if (_pLayerMode != PLayerMode.WEB_PLAYMODE) - { - Debug.LogWarning("[ChangePlayerSchema] 请先切换到 WebPlayMode 再设置子模式"); - return; - } - - var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup; - - // 清理现有子模式宏,保留其他所有宏 - var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget) - .Split(';') - .Where(d => !string.IsNullOrEmpty(d)) - .Where(d => !Enum.GetNames(typeof(WebSubMode)).Contains(d)) - .ToList(); - - // 添加新的子模式宏 - defines.Add(subMode.ToString()); - CustomEditorPrefs.SetString("WebSubMode", subMode.ToString()); - - ApplyDefines(defines); - Debug.Log($"[ChangePlayerSchema] Web 子模式切换至: {subMode}"); - } + private static void ApplyDefines(System.Collections.Generic.List defines) { @@ -171,12 +118,6 @@ namespace Stary.Evo.Editor EDITOR_SIMULATEMODE, // 编辑器调试模式 HOST_PLAYMODE, // 联机运行模式 LOCAL_PLAYMODE, // 本地运行模式 - WEB_PLAYMODE // Web 运行模式(包含子模式) - } - - // Web 子模式枚举 - public enum WebSubMode - { WEB_NORMAL, // WebGL 普通模式 WECHAT_MINIGAME // 微信小程序模式 } diff --git a/Assets/00.StaryEvoTools/package.json b/Assets/00.StaryEvoTools/package.json index 7e57d5a..80a8a79 100644 --- a/Assets/00.StaryEvoTools/package.json +++ b/Assets/00.StaryEvoTools/package.json @@ -1,6 +1,6 @@ { "name": "com.staryevo.tools", - "version": "1.4.7", + "version": "1.4.8", "displayName": "00.StaryEvo.Tools", "description": "This is an Framework package(后台服务器版本,端口9527)", "unity": "2021.3",