1
- using System . Collections . Generic ;
1
+ using System ;
2
+ using System . Collections . Generic ;
2
3
using UnityEngine ;
3
4
using WeChatWASM ;
4
-
5
+ using System . Collections ;
6
+ using System . Threading ;
5
7
public class SystemButton : Details
6
8
{
7
9
private WXFeedbackButton _feedbackButton ;
@@ -12,8 +14,8 @@ private void Start()
12
14
var result = WX . GetLaunchOptionsSync ( ) ;
13
15
Debug . Log ( JsonUtility . ToJson ( result ) ) ;
14
16
15
- CreateGameClubButton ( ) ;
16
- CreateFeedbackButton ( ) ;
17
+ StartCoroutine ( CreateGameClubButton ( 1.0f ) ) ;
18
+ StartCoroutine ( CreateFeedbackButton ( 1.0f ) ) ;
17
19
18
20
WX . GetSetting ( new GetSettingOption ( )
19
21
{
@@ -36,53 +38,54 @@ private void Start()
36
38
Debug . Log ( "GetSetting fail" + JsonUtility . ToJson ( res ) ) ;
37
39
}
38
40
} ) ;
39
-
41
+
40
42
GameManager . Instance . detailsController . BindExtraButtonAction ( 0 , GameClubButtonSwitch ) ;
41
43
GameManager . Instance . detailsController . BindExtraButtonAction ( 1 , FeedbackButtonSwitch ) ;
42
44
GameManager . Instance . detailsController . BindExtraButtonAction ( 2 , RequestSubscribeSystemMessage ) ;
43
45
GameManager . Instance . detailsController . BindExtraButtonAction ( 3 , OpenCustomerServiceChat ) ;
44
46
}
45
-
46
- private void CreateGameClubButton ( )
47
+
48
+ IEnumerator CreateGameClubButton ( float delay )
47
49
{
48
- var screenWidth = ( int ) GameManager . Instance . systemInfo . screenWidth ;
50
+ yield return new WaitForSeconds ( delay ) ;
51
+
52
+ Vector2 size = GameManager . Instance . detailsController . GetInitialButtonSize ( ) ;
53
+ Vector2 position = GameManager . Instance . detailsController . GetButtonPosition ( 0 ) ;
54
+ var systemInfo = WX . GetSystemInfoSync ( ) ;
49
55
_gameClubButton = WX . CreateGameClubButton ( new WXCreateGameClubButtonParam ( )
50
56
{
51
- type = GameClubButtonType . image ,
52
- text = "游戏圈" ,
53
- icon = GameClubButtonIcon . green ,
57
+ type = GameClubButtonType . text ,
54
58
style = new GameClubButtonStyle ( )
55
59
{
56
- left = screenWidth - 40 - 10 ,
57
- top = 260 ,
58
- width = 40 ,
59
- height = 40 ,
60
+ left = Math . Abs ( ( int ) ( position . x / systemInfo . pixelRatio ) ) ,
61
+ top = Math . Abs ( ( int ) ( position . y / systemInfo . pixelRatio ) ) ,
62
+ width = ( int ) ( size . x * systemInfo . screenWidth / 1080f ) ,
63
+ height = ( int ) ( size . y * systemInfo . screenWidth / 1080f ) ,
60
64
}
61
65
} ) ;
62
66
}
63
-
64
- private void CreateFeedbackButton ( )
67
+
68
+ IEnumerator CreateFeedbackButton ( float delay )
65
69
{
70
+ yield return new WaitForSeconds ( delay ) ;
71
+
72
+ Vector2 size = GameManager . Instance . detailsController . GetInitialButtonSize ( ) ;
73
+ Vector2 position = GameManager . Instance . detailsController . GetButtonPosition ( 1 ) ;
74
+ var systemInfo = WX . GetSystemInfoSync ( ) ;
66
75
_feedbackButton = WX . CreateFeedbackButton ( new CreateOpenSettingButtonOption ( )
67
76
{
68
77
type = "text" ,
69
- text = "打开意见反馈页面 " ,
78
+ text = "" ,
70
79
style = new OptionStyle ( )
71
80
{
72
- left = 10 ,
73
- top = 260 ,
74
- width = 200 ,
75
- height = 40 ,
76
- lineHeight = 40 ,
77
- backgroundColor = "#ff0000" ,
78
- color = "#ffffff" ,
79
- textAlign = "center" ,
80
- fontSize = 16 ,
81
- borderRadius = 4 ,
81
+ left = Math . Abs ( ( int ) ( position . x / systemInfo . pixelRatio ) ) ,
82
+ top = Math . Abs ( ( int ) ( position . y / systemInfo . pixelRatio ) ) ,
83
+ width = ( int ) ( size . x * systemInfo . screenWidth / 1080f ) ,
84
+ height = ( int ) ( size . y * systemInfo . screenWidth / 1080f ) ,
82
85
}
83
86
} ) ;
84
87
}
85
-
88
+
86
89
// 进入客服会话
87
90
protected override void TestAPI ( string [ ] args )
88
91
{
@@ -95,43 +98,43 @@ protected override void TestAPI(string[] args)
95
98
}
96
99
97
100
private bool _isGameClubShow = false ;
98
-
101
+
99
102
// 切换游戏圈按钮显示/隐藏
100
103
private void GameClubButtonSwitch ( )
101
104
{
102
- if ( _isGameClubShow )
103
- {
104
- // 显示游戏圈按钮
105
- _gameClubButton . Show ( ) ;
106
- GameManager . Instance . detailsController . ChangeExtraButtonText ( 0 , "隐藏游戏圈按钮" ) ;
107
- }
108
- else
109
- {
110
- // 隐藏游戏圈按钮
111
- _gameClubButton . Hide ( ) ;
112
- GameManager . Instance . detailsController . ChangeExtraButtonText ( 0 , "显示游戏圈按钮" ) ;
113
- }
114
- _isGameClubShow = ! _isGameClubShow ;
105
+ // if (_isGameClubShow)
106
+ // {
107
+ // // 显示游戏圈按钮
108
+ // _gameClubButton.Show();
109
+ // GameManager.Instance.detailsController.ChangeExtraButtonText(0, "隐藏游戏圈按钮");
110
+ // }
111
+ // else
112
+ // {
113
+ // // 隐藏游戏圈按钮
114
+ // _gameClubButton.Hide();
115
+ // GameManager.Instance.detailsController.ChangeExtraButtonText(0, "显示游戏圈按钮");
116
+ // }
117
+ // _isGameClubShow = !_isGameClubShow;
115
118
}
116
-
119
+
117
120
private bool _isFeedbackShow = true ;
118
-
121
+
119
122
// 切换意见反馈按钮显示/隐藏
120
123
private void FeedbackButtonSwitch ( )
121
124
{
122
- if ( _isFeedbackShow )
123
- {
124
- // 隐藏意见反馈按钮
125
- _feedbackButton . Hide ( ) ;
126
- GameManager . Instance . detailsController . ChangeExtraButtonText ( 1 , "显示意见反馈按钮" ) ;
127
- }
128
- else
129
- {
130
- // 显示意见反馈按钮
131
- _feedbackButton . Show ( ) ;
132
- GameManager . Instance . detailsController . ChangeExtraButtonText ( 1 , "隐藏意见反馈按钮" ) ;
133
- }
134
- _isFeedbackShow = ! _isFeedbackShow ;
125
+ // if (_isFeedbackShow)
126
+ // {
127
+ // // 隐藏意见反馈按钮
128
+ // _feedbackButton.Hide();
129
+ // GameManager.Instance.detailsController.ChangeExtraButtonText(1, "显示意见反馈按钮");
130
+ // }
131
+ // else
132
+ // {
133
+ // // 显示意见反馈按钮
134
+ // _feedbackButton.Show();
135
+ // GameManager.Instance.detailsController.ChangeExtraButtonText(1, "隐藏意见反馈按钮");
136
+ // }
137
+ // _isFeedbackShow = !_isFeedbackShow;
135
138
}
136
139
137
140
// 调起小游戏系统订阅消息界面
@@ -140,10 +143,12 @@ private void RequestSubscribeSystemMessage()
140
143
WX . RequestSubscribeSystemMessage ( new RequestSubscribeSystemMessageOption ( )
141
144
{
142
145
msgTypeList = new string [ ] { "SYS_MSG_TYPE_INTERACTIVE" } ,
143
- success = ( res ) => {
146
+ success = ( res ) =>
147
+ {
144
148
Debug . Log ( res ) ;
145
149
} ,
146
- fail = ( res ) => {
150
+ fail = ( res ) =>
151
+ {
147
152
Debug . Log ( JsonUtility . ToJson ( res ) ) ;
148
153
}
149
154
} ) ;
@@ -161,7 +166,7 @@ private void OpenCustomerServiceChat()
161
166
corpId = "123" ,
162
167
} ) ;
163
168
}
164
-
169
+
165
170
166
171
private void FeedbackButtonOnTap ( )
167
172
{
@@ -180,27 +185,31 @@ private void FeedbackButtonChangeText()
180
185
{
181
186
_feedbackButton . text = "跳转到意见反馈页面" ;
182
187
}
183
-
184
-
188
+
189
+
185
190
private void GameClubButtonDestroy ( )
186
191
{
187
192
Debug . Log ( "gameclub destroy" ) ;
188
193
_gameClubButton . Destroy ( ) ;
189
194
}
190
-
195
+
191
196
private void FeedbackButtonDestroy ( )
192
197
{
193
198
Debug . Log ( "feedback destroy" ) ;
194
199
_feedbackButton . Destroy ( ) ;
195
200
}
196
-
201
+
197
202
public void Destroy ( )
198
203
{
199
- if ( _gameClubButton != null ) {
204
+ if ( _gameClubButton != null )
205
+ {
206
+ _gameClubButton . Hide ( ) ;
200
207
GameClubButtonDestroy ( ) ;
201
208
_gameClubButton = null ;
202
209
}
203
- if ( _feedbackButton != null ) {
210
+ if ( _feedbackButton != null )
211
+ {
212
+ _feedbackButton . Hide ( ) ;
204
213
FeedbackButtonDestroy ( ) ;
205
214
_feedbackButton = null ;
206
215
}
0 commit comments