1- using System . Collections . Generic ;
1+ using System ;
2+ using System . Collections . Generic ;
23using UnityEngine ;
34using WeChatWASM ;
4-
5+ using System . Collections ;
6+ using System . Threading ;
57public class SystemButton : Details
68{
79 private WXFeedbackButton _feedbackButton ;
@@ -12,8 +14,8 @@ private void Start()
1214 var result = WX . GetLaunchOptionsSync ( ) ;
1315 Debug . Log ( JsonUtility . ToJson ( result ) ) ;
1416
15- CreateGameClubButton ( ) ;
16- CreateFeedbackButton ( ) ;
17+ StartCoroutine ( CreateGameClubButton ( 1.0f ) ) ;
18+ StartCoroutine ( CreateFeedbackButton ( 1.0f ) ) ;
1719
1820 WX . GetSetting ( new GetSettingOption ( )
1921 {
@@ -36,53 +38,54 @@ private void Start()
3638 Debug . Log ( "GetSetting fail" + JsonUtility . ToJson ( res ) ) ;
3739 }
3840 } ) ;
39-
41+
4042 GameManager . Instance . detailsController . BindExtraButtonAction ( 0 , GameClubButtonSwitch ) ;
4143 GameManager . Instance . detailsController . BindExtraButtonAction ( 1 , FeedbackButtonSwitch ) ;
4244 GameManager . Instance . detailsController . BindExtraButtonAction ( 2 , RequestSubscribeSystemMessage ) ;
4345 GameManager . Instance . detailsController . BindExtraButtonAction ( 3 , OpenCustomerServiceChat ) ;
4446 }
45-
46- private void CreateGameClubButton ( )
47+
48+ IEnumerator CreateGameClubButton ( float delay )
4749 {
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 ( ) ;
4955 _gameClubButton = WX . CreateGameClubButton ( new WXCreateGameClubButtonParam ( )
5056 {
51- type = GameClubButtonType . image ,
52- text = "游戏圈" ,
53- icon = GameClubButtonIcon . green ,
57+ type = GameClubButtonType . text ,
5458 style = new GameClubButtonStyle ( )
5559 {
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 ) ,
6064 }
6165 } ) ;
6266 }
63-
64- private void CreateFeedbackButton ( )
67+
68+ IEnumerator CreateFeedbackButton ( float delay )
6569 {
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 ( ) ;
6675 _feedbackButton = WX . CreateFeedbackButton ( new CreateOpenSettingButtonOption ( )
6776 {
6877 type = "text" ,
69- text = "打开意见反馈页面 " ,
78+ text = "" ,
7079 style = new OptionStyle ( )
7180 {
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 ) ,
8285 }
8386 } ) ;
8487 }
85-
88+
8689 // 进入客服会话
8790 protected override void TestAPI ( string [ ] args )
8891 {
@@ -95,43 +98,43 @@ protected override void TestAPI(string[] args)
9598 }
9699
97100 private bool _isGameClubShow = false ;
98-
101+
99102 // 切换游戏圈按钮显示/隐藏
100103 private void GameClubButtonSwitch ( )
101104 {
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;
115118 }
116-
119+
117120 private bool _isFeedbackShow = true ;
118-
121+
119122 // 切换意见反馈按钮显示/隐藏
120123 private void FeedbackButtonSwitch ( )
121124 {
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;
135138 }
136139
137140 // 调起小游戏系统订阅消息界面
@@ -140,10 +143,12 @@ private void RequestSubscribeSystemMessage()
140143 WX . RequestSubscribeSystemMessage ( new RequestSubscribeSystemMessageOption ( )
141144 {
142145 msgTypeList = new string [ ] { "SYS_MSG_TYPE_INTERACTIVE" } ,
143- success = ( res ) => {
146+ success = ( res ) =>
147+ {
144148 Debug . Log ( res ) ;
145149 } ,
146- fail = ( res ) => {
150+ fail = ( res ) =>
151+ {
147152 Debug . Log ( JsonUtility . ToJson ( res ) ) ;
148153 }
149154 } ) ;
@@ -161,7 +166,7 @@ private void OpenCustomerServiceChat()
161166 corpId = "123" ,
162167 } ) ;
163168 }
164-
169+
165170
166171 private void FeedbackButtonOnTap ( )
167172 {
@@ -180,27 +185,31 @@ private void FeedbackButtonChangeText()
180185 {
181186 _feedbackButton . text = "跳转到意见反馈页面" ;
182187 }
183-
184-
188+
189+
185190 private void GameClubButtonDestroy ( )
186191 {
187192 Debug . Log ( "gameclub destroy" ) ;
188193 _gameClubButton . Destroy ( ) ;
189194 }
190-
195+
191196 private void FeedbackButtonDestroy ( )
192197 {
193198 Debug . Log ( "feedback destroy" ) ;
194199 _feedbackButton . Destroy ( ) ;
195200 }
196-
201+
197202 public void Destroy ( )
198203 {
199- if ( _gameClubButton != null ) {
204+ if ( _gameClubButton != null )
205+ {
206+ _gameClubButton . Hide ( ) ;
200207 GameClubButtonDestroy ( ) ;
201208 _gameClubButton = null ;
202209 }
203- if ( _feedbackButton != null ) {
210+ if ( _feedbackButton != null )
211+ {
212+ _feedbackButton . Hide ( ) ;
204213 FeedbackButtonDestroy ( ) ;
205214 _feedbackButton = null ;
206215 }
0 commit comments