Skip to content

Commit 79cfbd5

Browse files
author
v_shanxia
committed
fix:界面-窗口 添加可视化表现
1 parent 620f9e0 commit 79cfbd5

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

Demo/API_V2/Assets/API/GUI/Window/Window.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
public class Window : Details
88
{
99
private bool _isListening = false;
10+
private float timer = 0f;
11+
private float interval = 5f; // 定时器间隔
1012

1113
private readonly Action<OnWindowResizeListenerResult> _onWindowResize = (res) =>
1214
{
@@ -33,6 +35,39 @@ protected override void TestAPI(string[] args)
3335
);
3436
}
3537

38+
private void Start()
39+
{
40+
// 绑定额外的按钮操作
41+
GameManager.Instance.detailsController.BindExtraButtonAction(0, setDeviceOrientation);
42+
}
43+
44+
private void Update()
45+
{
46+
if(timer >= 20f){
47+
timer += Time.deltaTime; // 每帧累加时间
48+
Debug.Log(timer);
49+
}
50+
if (timer >= interval + 20)
51+
{
52+
Debug.Log("定时器触发!");
53+
WX.SetDeviceOrientation(new SetDeviceOrientationOption()
54+
{
55+
value = "portrait",
56+
});
57+
timer = 0f; // 重置计时器(如果是周期性触发则不需要重置)
58+
}
59+
}
60+
61+
private void setDeviceOrientation()
62+
{
63+
Debug.Log("设置为横屏");
64+
WX.SetDeviceOrientation(new SetDeviceOrientationOption()
65+
{
66+
value = "landscape",
67+
});
68+
69+
timer = 20f;
70+
}
3671
private void OnDestroy()
3772
{
3873
WX.OffWindowResize(_onWindowResize);

Demo/API_V2/Assets/API/GUI/Window/WindowSO.asset

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ MonoBehaviour:
1515
entryName: "\u7A97\u53E3"
1616
entryOrder: 0
1717
entryScriptTypeName: Window
18-
entryAPI: "onWindowResize \uFF5C offWindowResize"
18+
entryAPI: "OnWindowResize \uFF5C OffWindowResize"
1919
entryDescription:
2020
optionList: []
2121
initialButtonText: "\u5F00\u59CB\u76D1\u542C"
22-
extraButtonList: []
22+
extraButtonList:
23+
- buttonText: "\u7A97\u53E3\u53D8\u6210\u6A2A\u5C4F(5s\u540E\u6062\u590D)"
2324
initialResultList: []

0 commit comments

Comments
 (0)