File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed
Demo/API_V2/Assets/API/GUI/Window Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 7
7
public class Window : Details
8
8
{
9
9
private bool _isListening = false ;
10
+ private float timer = 0f ;
11
+ private float interval = 5f ; // 定时器间隔
10
12
11
13
private readonly Action < OnWindowResizeListenerResult > _onWindowResize = ( res ) =>
12
14
{
@@ -33,6 +35,39 @@ protected override void TestAPI(string[] args)
33
35
) ;
34
36
}
35
37
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
+ }
36
71
private void OnDestroy ( )
37
72
{
38
73
WX . OffWindowResize ( _onWindowResize ) ;
Original file line number Diff line number Diff line change @@ -15,9 +15,10 @@ MonoBehaviour:
15
15
entryName : " \u7A97\u53E3 "
16
16
entryOrder : 0
17
17
entryScriptTypeName : Window
18
- entryAPI : " onWindowResize \uFF5C offWindowResize "
18
+ entryAPI : " OnWindowResize \uFF5C OffWindowResize "
19
19
entryDescription :
20
20
optionList : []
21
21
initialButtonText : " \u5F00\u59CB\u76D1\u542C "
22
- extraButtonList : []
22
+ extraButtonList :
23
+ - buttonText : " \u7A97\u53E3\u53D8\u6210\u6A2A\u5C4F (5s\u540E\u6062\u590D )"
23
24
initialResultList : []
You can’t perform that action at this time.
0 commit comments