Skip to content

Commit 5046c88

Browse files
committed
merged gameclub related function into a collection
1 parent 7575427 commit 5046c88

File tree

7 files changed

+118
-109
lines changed

7 files changed

+118
-109
lines changed

Demo/API_V2/Assets/API/OpenInterface/GameClub/GameClub SO.asset

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ MonoBehaviour:
1313
m_Name: GameClub SO
1414
m_EditorClassIdentifier:
1515
entryScriptTypeName: GameClub
16-
entryName: "\u6E38\u620F\u5708\u6570\u636E"
17-
entryAPI: getGameClubData
16+
entryName: "\u6E38\u620F\u5708"
17+
entryAPI: "getGameClubData\uFF0C createGameClubButton"
1818
entryDescription:
1919
optionList: []
2020
initialButtonText: "\u83B7\u53D6\u6E38\u620F\u5708\u6570\u636E"
21-
extraButtonList: []
21+
extraButtonList:
22+
- buttonText: "\u8FDB\u5165\u6E38\u620F\u5708"
2223
initialResultList: []

Demo/API_V2/Assets/API/OpenInterface/GameClub/GameClub.cs

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,43 @@
44
using UnityEngine;
55
using LitJson;
66
using WeChatWASM;
7+
using System.Threading;
78

89
public class GameClub : Details
910
{
10-
private int[] _data = { 1, 2 };
11+
private int[] _data = { 1, 3, 4 };
12+
13+
private WXGameClubButton _gameClubButton;
1114

1215
// Start is called before the first frame update
1316
private void Start()
1417
{
15-
//Placeholder for later tests
18+
var result = WX.GetLaunchOptionsSync();
19+
Debug.Log(JsonUtility.ToJson(result));
20+
21+
StartCoroutine(CreateGameClubButton(1.0f));
22+
23+
GameManager.Instance.detailsController.BindExtraButtonAction(0, GameClubButtonSwitch);
24+
}
25+
26+
IEnumerator CreateGameClubButton(float delay)
27+
{
28+
yield return new WaitForSeconds(delay);
29+
30+
Vector2 size = GameManager.Instance.detailsController.GetInitialButtonSize();
31+
Vector2 position = GameManager.Instance.detailsController.GetButtonPosition(0);
32+
var systemInfo = WX.GetSystemInfoSync();
33+
_gameClubButton = WX.CreateGameClubButton(new WXCreateGameClubButtonParam()
34+
{
35+
type = GameClubButtonType.text,
36+
style = new GameClubButtonStyle()
37+
{
38+
left = Math.Abs((int)(position.x / systemInfo.pixelRatio)),
39+
top = Math.Abs((int)(position.y / systemInfo.pixelRatio)),
40+
width = (int)(size.x * systemInfo.screenWidth / 1080f),
41+
height = (int)(size.y * systemInfo.screenWidth / 1080f),
42+
}
43+
});
1644
}
1745

1846
// ²âÊÔ API
@@ -52,4 +80,42 @@ private void getGameClubData()
5280
WX.GetGameClubData(option);
5381
}
5482

83+
private bool _isGameClubShow = false;
84+
85+
// Çл»ÓÎϷȦ°´Å¥ÏÔʾ/Òþ²Ø
86+
private void GameClubButtonSwitch()
87+
{
88+
//if (_isGameClubShow)
89+
//{
90+
// // ÏÔʾÓÎϷȦ°´Å¥
91+
// _gameClubButton.Show();
92+
// GameManager.Instance.detailsController.ChangeExtraButtonText(0, "Òþ²ØÓÎϷȦ°´Å¥");
93+
//}
94+
//else
95+
//{
96+
// // Òþ²ØÓÎϷȦ°´Å¥
97+
// _gameClubButton.Hide();
98+
// GameManager.Instance.detailsController.ChangeExtraButtonText(0, "ÏÔʾÓÎϷȦ°´Å¥");
99+
//}
100+
//_isGameClubShow = !_isGameClubShow;
101+
}
102+
103+
private void GameClubButtonDestroy()
104+
{
105+
Debug.Log("gameclub destroy");
106+
_gameClubButton.Destroy();
107+
}
108+
109+
public void Destroy()
110+
{
111+
if (_gameClubButton != null)
112+
{
113+
_gameClubButton.Hide();
114+
GameClubButtonDestroy();
115+
_gameClubButton = null;
116+
}
117+
}
118+
55119
}
120+
121+

Demo/API_V2/Assets/API/OpenInterface/SystemButton/SystemButton.cs

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
public class SystemButton : Details
88
{
99
private WXFeedbackButton _feedbackButton;
10-
private WXGameClubButton _gameClubButton;
1110

1211
private void Start()
1312
{
1413
var result = WX.GetLaunchOptionsSync();
1514
Debug.Log(JsonUtility.ToJson(result));
1615

17-
StartCoroutine(CreateGameClubButton(1.0f));
1816
StartCoroutine(CreateFeedbackButton(1.0f));
1917

2018
WX.GetSetting(new GetSettingOption()
@@ -39,30 +37,9 @@ private void Start()
3937
}
4038
});
4139

42-
GameManager.Instance.detailsController.BindExtraButtonAction(0, GameClubButtonSwitch);
43-
GameManager.Instance.detailsController.BindExtraButtonAction(1, FeedbackButtonSwitch);
44-
GameManager.Instance.detailsController.BindExtraButtonAction(2, RequestSubscribeSystemMessage);
45-
GameManager.Instance.detailsController.BindExtraButtonAction(3, OpenCustomerServiceChat);
46-
}
47-
48-
IEnumerator CreateGameClubButton(float delay)
49-
{
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();
55-
_gameClubButton = WX.CreateGameClubButton(new WXCreateGameClubButtonParam()
56-
{
57-
type = GameClubButtonType.text,
58-
style = new GameClubButtonStyle()
59-
{
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),
64-
}
65-
});
40+
GameManager.Instance.detailsController.BindExtraButtonAction(0, FeedbackButtonSwitch);
41+
GameManager.Instance.detailsController.BindExtraButtonAction(1, RequestSubscribeSystemMessage);
42+
GameManager.Instance.detailsController.BindExtraButtonAction(2, OpenCustomerServiceChat);
6643
}
6744

6845
IEnumerator CreateFeedbackButton(float delay)
@@ -97,25 +74,6 @@ protected override void TestAPI(string[] args)
9774
});
9875
}
9976

100-
private bool _isGameClubShow = false;
101-
102-
// 切换游戏圈按钮显示/隐藏
103-
private void GameClubButtonSwitch()
104-
{
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;
118-
}
11977

12078
private bool _isFeedbackShow = true;
12179

@@ -186,13 +144,6 @@ private void FeedbackButtonChangeText()
186144
_feedbackButton.text = "跳转到意见反馈页面";
187145
}
188146

189-
190-
private void GameClubButtonDestroy()
191-
{
192-
Debug.Log("gameclub destroy");
193-
_gameClubButton.Destroy();
194-
}
195-
196147
private void FeedbackButtonDestroy()
197148
{
198149
Debug.Log("feedback destroy");
@@ -201,12 +152,6 @@ private void FeedbackButtonDestroy()
201152

202153
public void Destroy()
203154
{
204-
if (_gameClubButton != null)
205-
{
206-
_gameClubButton.Hide();
207-
GameClubButtonDestroy();
208-
_gameClubButton = null;
209-
}
210155
if (_feedbackButton != null)
211156
{
212157
_feedbackButton.Hide();

Demo/API_V2/Assets/API/OpenInterface/SystemButton/SystemButtonSO.asset

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ MonoBehaviour:
1919
optionList: []
2020
initialButtonText: "\u8FDB\u5165\u5BA2\u670D\u4F1A\u8BDD"
2121
extraButtonList:
22-
- buttonText: "\u8FDB\u5165\u6E38\u620F\u5708"
2322
- buttonText: "\u6253\u5F00\u610F\u89C1\u53CD\u9988\u9875\u9762"
2423
- buttonText: "\u8C03\u8D77\u5C0F\u6E38\u620F\u7CFB\u7EDF\u8BA2\u9605\u6D88\u606F\u754C\u9762"
2524
- buttonText: "\u6253\u5F00\u5FAE\u4FE1\u5BA2\u670D"

Demo/API_V2/Assets/WX-WASM-SDK-V2/Editor/MiniGameConfig.asset

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ MonoBehaviour:
1414
m_EditorClassIdentifier:
1515
ProjectConf:
1616
projectName: GameClubDemo
17-
Appid: wxb7d4485dbc1233ca
18-
CDN: http://127.0.0.1:8080
19-
assetLoadType: 0
17+
Appid: wxf616b60467bcfcaf
18+
CDN:
19+
assetLoadType: 1
2020
compressDataPackage: 0
2121
VideoUrl:
22-
DST: C:/Users/xiaoyuejin/Desktop/GameClubDemo
22+
DST: C:/Users/xiaoyuejin/Desktop/gametest
2323
StreamCDN:
2424
bundleHashLength: 32
2525
bundlePathIdentifier: StreamingAssets;

0 commit comments

Comments
 (0)