diff --git a/Demo/API_V2/Assets/API/GUI/Menu/Menu.cs b/Demo/API_V2/Assets/API/GUI/Menu/Menu.cs index 3fd53dd5..889af093 100644 --- a/Demo/API_V2/Assets/API/GUI/Menu/Menu.cs +++ b/Demo/API_V2/Assets/API/GUI/Menu/Menu.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; using LitJson; using UnityEngine; using WeChatWASM; public class Menu : Details { + private bool isMenuStyleDark = false; + private bool isStatusBarStyleBlack = false; private void Start() { // 绑定额外的按钮操作 @@ -24,13 +24,16 @@ protected override void TestAPI(string[] args) public void setMenuStyle() { + string style = isMenuStyleDark ? "light" : "dark"; + string toastMessage = $"设置{(isMenuStyleDark ? "浅色" : "深色")}菜单样式完成"; + WX.SetMenuStyle( new SetMenuStyleOption { - style = "light", + style = style, success = (res) => { - WX.ShowToast(new ShowToastOption { title = "设置成功" }); + WX.ShowToast(new ShowToastOption { title = toastMessage, icon = "none"}); }, fail = (res) => { @@ -42,6 +45,11 @@ public void setMenuStyle() } } ); + + isMenuStyleDark = !isMenuStyleDark; + GameManager.Instance.detailsController.ChangeInitialButtonText( + isMenuStyleDark ? "设置菜单栏浅色" : "设置菜单栏深色" + ); } public void getMenuButtonBoundingClientRect() @@ -50,19 +58,22 @@ public void getMenuButtonBoundingClientRect() // 访问成功,显示结果 WX.ShowModal( - new ShowModalOption() { content = "Access Success, Result: " + JsonMapper.ToJson(res) } + new ShowModalOption() { content = "GetMenuButtonBoundingClientRect Success, Result: " + JsonMapper.ToJson(res) } ); } public void setStatusBarStyle() { + string style = !isStatusBarStyleBlack ? "black" : "white"; // 修改逻辑 + string toastMessage = $"设置状态栏{(!isStatusBarStyleBlack ? "深色" : "白色")}样式完成"; // 修改逻辑 + WX.SetStatusBarStyle( new SetStatusBarStyleOption { - style = "black", + style = style, success = (res) => { - WX.ShowToast(new ShowToastOption { title = "设置成功" }); + WX.ShowToast(new ShowToastOption { title = toastMessage, icon = "none"}); }, fail = (res) => { @@ -74,5 +85,10 @@ public void setStatusBarStyle() } } ); + + isStatusBarStyleBlack = !isStatusBarStyleBlack; + GameManager.Instance.detailsController.ChangeExtraButtonText(1, + !isStatusBarStyleBlack ? "设置状态栏深色" : "设置状态栏白色" // 修改逻辑 + ); } -} +} \ No newline at end of file diff --git a/Demo/API_V2/Assets/API/GUI/Menu/MenuSO.asset b/Demo/API_V2/Assets/API/GUI/Menu/MenuSO.asset index d2d11aca..07f4dd38 100644 --- a/Demo/API_V2/Assets/API/GUI/Menu/MenuSO.asset +++ b/Demo/API_V2/Assets/API/GUI/Menu/MenuSO.asset @@ -14,17 +14,19 @@ MonoBehaviour: m_EditorClassIdentifier: entryScriptTypeName: Menu entryName: "\u83DC\u5355\u548C\u72B6\u6001\u680F" - entryAPI: 'setMenuStyle + entryAPI: 'SetMenuStyle - getMenuButtonBoundingClientRect + GetMenuButtonBoundingClientRect - setStatusBarStyle + SetStatusBarStyle ' - entryDescription: "\u4F7F\u7528setStatusBarStyle\uFF0C\u9700\u8981\u5728json\u91CC\u6DFB\u52A0showStatusBar" + entryDescription: "\u4F7F\u7528setStatusBarStyle\uFF0C\u9700\u8981\u5728game.json\u91CC\u6DFB\u52A0\n\"showStatusBar\": + true" optionList: [] - initialButtonText: "\u8BBE\u7F6E\u83DC\u5355\u6837\u5F0F" + initialButtonText: "\u8BBE\u7F6E\u83DC\u5355\u6837\u5F0F\u6DF1\u8272" extraButtonList: - buttonText: "\u83B7\u53D6\u83DC\u5355\u6309\u94AE\u5E03\u5C40\u4F4D\u7F6E\u4FE1\u606F" - - buttonText: "\u8BBE\u7F6E\u72B6\u6001\u680F\u6837\u5F0F" + - buttonText: "\u8BBE\u7F6E\u72B6\u6001\u680F\u6DF1\u8272" initialResultList: [] + entryOrder: 0