diff --git a/Demo/API_V2/Assets/API/GUI/Window/Window.cs b/Demo/API_V2/Assets/API/GUI/Window/Window.cs index 40a45a8a..76bc461b 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 77363819..d198b5d5 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: []