From 79cfbd50242e9d4a4c460d7f2a5bac97214f2b12 Mon Sep 17 00:00:00 2001 From: v_shanxia Date: Mon, 26 May 2025 09:58:08 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E7=95=8C=E9=9D=A2-=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=20=E6=B7=BB=E5=8A=A0=E5=8F=AF=E8=A7=86=E5=8C=96?= =?UTF-8?q?=E8=A1=A8=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demo/API_V2/Assets/API/GUI/Window/Window.cs | 35 +++++++++++++++++++ .../Assets/API/GUI/Window/WindowSO.asset | 5 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Demo/API_V2/Assets/API/GUI/Window/Window.cs b/Demo/API_V2/Assets/API/GUI/Window/Window.cs index 40a45a8a1..76bc461b4 100644 --- a/Demo/API_V2/Assets/API/GUI/Window/Window.cs +++ b/Demo/API_V2/Assets/API/GUI/Window/Window.cs @@ -7,6 +7,8 @@ public class Window : Details { private bool _isListening = false; + private float timer = 0f; + private float interval = 5f; // 定时器间隔 private readonly Action _onWindowResize = (res) => { @@ -33,6 +35,39 @@ protected override void TestAPI(string[] args) ); } + private void Start() + { + // 绑定额外的按钮操作 + GameManager.Instance.detailsController.BindExtraButtonAction(0, setDeviceOrientation); + } + + private void Update() + { + if(timer >= 20f){ + timer += Time.deltaTime; // 每帧累加时间 + Debug.Log(timer); + } + if (timer >= interval + 20) + { + Debug.Log("定时器触发!"); + WX.SetDeviceOrientation(new SetDeviceOrientationOption() + { + value = "portrait", + }); + timer = 0f; // 重置计时器(如果是周期性触发则不需要重置) + } + } + + private void setDeviceOrientation() + { + Debug.Log("设置为横屏"); + WX.SetDeviceOrientation(new SetDeviceOrientationOption() + { + value = "landscape", + }); + + timer = 20f; + } private void OnDestroy() { WX.OffWindowResize(_onWindowResize); diff --git a/Demo/API_V2/Assets/API/GUI/Window/WindowSO.asset b/Demo/API_V2/Assets/API/GUI/Window/WindowSO.asset index 773638191..d198b5d5c 100644 --- a/Demo/API_V2/Assets/API/GUI/Window/WindowSO.asset +++ b/Demo/API_V2/Assets/API/GUI/Window/WindowSO.asset @@ -15,9 +15,10 @@ MonoBehaviour: entryName: "\u7A97\u53E3" entryOrder: 0 entryScriptTypeName: Window - entryAPI: "onWindowResize \uFF5C offWindowResize" + entryAPI: "OnWindowResize \uFF5C OffWindowResize" entryDescription: optionList: [] initialButtonText: "\u5F00\u59CB\u76D1\u542C" - extraButtonList: [] + extraButtonList: + - buttonText: "\u7A97\u53E3\u53D8\u6210\u6A2A\u5C4F(5s\u540E\u6062\u590D)" initialResultList: []