Skip to content

Commit 8a1d854

Browse files
committed
test format
1 parent 072b3ae commit 8a1d854

File tree

109 files changed

+3931
-1920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+3931
-1920
lines changed

Demo/API_V2/.editorconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ indent_style = space
99
indent_size = 4
1010
end_of_line = crlf
1111
charset = utf-8
12-
trim_trailing_whitespace = false
12+
trim_trailing_whitespace = true
1313
insert_final_newline = false
1414

1515
# C# files
1616
[*.cs]
1717
# C# formatting options: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options
18-
csharp_new_line_before_open_brace = none
19-
csharp_new_line_before_else = false
20-
csharp_new_line_before_catch = false
21-
csharp_new_line_before_finally = false
18+
csharp_new_line_before_open_brace = all
19+
csharp_new_line_before_else = true
20+
csharp_new_line_before_catch = true
21+
csharp_new_line_before_finally = true
2222
csharp_new_line_before_members_in_object_initializers = true
2323
csharp_new_line_before_members_in_anonymous_types = true
2424
csharp_new_line_between_query_expression_clauses = true

Demo/API_V2/Assets/API/Ad/AdWithAudio/AdWithAudio.cs

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,41 @@
99
using UnityEngine.Audio;
1010
using UnityEngine.Networking;
1111

12-
public class AdWithAudio : Details {
12+
public class AdWithAudio : Details
13+
{
1314

1415
private WXRewardedVideoAd _rewardedVideoAd;
1516
public AudioSource audioSource;
1617
public AudioClip audioClipCDN;
1718

18-
private void Start() {
19+
private void Start()
20+
{
1921
StartCoroutine(LoadCDNAudio());
2022

2123

2224
// 创建激励视频广告组件
23-
_rewardedVideoAd = WX.CreateRewardedVideoAd(new WXCreateRewardedVideoAdParam() {
25+
_rewardedVideoAd = WX.CreateRewardedVideoAd(new WXCreateRewardedVideoAdParam()
26+
{
2427
// adUnitId 请填写自己的广告位 ID
2528
adUnitId = "adunit-881d549c5a14a7e3"
2629
});
2730

28-
_rewardedVideoAd.OnError(err => {
31+
_rewardedVideoAd.OnError(err =>
32+
{
2933
Debug.Log(JsonUtility.ToJson(err));
3034
});
3135

3236
GameManager.Instance.detailsController.BindExtraButtonAction(0, PlayCDN);
3337
}
3438

3539
// 创建激励视频广告组件并挂载事件、预加载广告
36-
protected override void TestAPI(string[] args) {
40+
protected override void TestAPI(string[] args)
41+
{
3742
ShowAd();
3843
}
3944

40-
IEnumerator LoadCDNAudio() {
45+
IEnumerator LoadCDNAudio()
46+
{
4147
// 创建一个新的游戏对象
4248
GameObject newGameObject = new GameObject("New GameObject");
4349

@@ -48,43 +54,55 @@ IEnumerator LoadCDNAudio() {
4854
Uri uri = new Uri(uriString);
4955
UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(uri, AudioType.MPEG);
5056
yield return request.SendWebRequest();
51-
if (request.result == UnityWebRequest.Result.Success) {
57+
if (request.result == UnityWebRequest.Result.Success)
58+
{
5259
audioClipCDN = DownloadHandlerAudioClip.GetContent(request);
5360
// yield return new WaitUntil(() => audioClipCDN.loadState == AudioDataLoadState.Loaded);
5461
// Debug.Log("audioClipCDN loaded, clip length: " + audioClipCDN.length);
55-
} else {
62+
}
63+
else
64+
{
5665
Debug.Log("request error: " + request.error);
5766
}
5867
}
5968

60-
public void PlayCDN() {
61-
if (audioClipCDN != null) {
69+
public void PlayCDN()
70+
{
71+
if (audioClipCDN != null)
72+
{
6273
audioSource.clip = audioClipCDN;
6374
audioSource.loop = true;
6475
audioSource.Play();
6576
}
6677
}
6778

6879
// 展示广告
69-
private void ShowAd() {
70-
_rewardedVideoAd.Show(res => {
80+
private void ShowAd()
81+
{
82+
_rewardedVideoAd.Show(res =>
83+
{
7184
Debug.Log("Show success");
7285
Debug.Log(JsonUtility.ToJson(res));
73-
}, err => {
86+
}, err =>
87+
{
7488
Debug.Log(JsonUtility.ToJson(err));
75-
_rewardedVideoAd.Load(res => {
89+
_rewardedVideoAd.Load(res =>
90+
{
7691
Debug.Log("load success");
7792
_rewardedVideoAd.Show();
78-
}, err => {
93+
}, err =>
94+
{
7995
Debug.Log("load fail");
8096
Debug.Log(JsonUtility.ToJson(err));
8197
});
8298
});
8399
}
84100

85101

86-
public void Destroy() {
87-
if (audioSource != null) {
102+
public void Destroy()
103+
{
104+
if (audioSource != null)
105+
{
88106
audioSource.clip = null;
89107
audioSource = null;
90108
}
Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,90 @@
11
using UnityEngine;
22
using WeChatWASM;
33

4-
public class BannerAd : Details {
4+
public class BannerAd : Details
5+
{
56
private WXBannerAd _bannerAd;
67

78
private bool _isShow = false;
89

9-
private void Start() {
10+
private void Start()
11+
{
1012
// 绑定按钮事件
1113
GameManager.Instance.detailsController.BindExtraButtonAction(0, SwitchAdState);
1214
GameManager.Instance.detailsController.BindExtraButtonAction(1, DestroyAd);
1315
}
1416

1517
// 创建预设的 Banner 广告组件并挂载事件
1618
// 如需自定义style请调用WX.CreateBannerAd(WXCreateBannerAdParam param)接口
17-
protected override void TestAPI(string[] args) {
19+
protected override void TestAPI(string[] args)
20+
{
1821
// adUnitId 请填写自己的广告位 ID
1922
// 创建预设的 Banner 广告
2023
_bannerAd = WX.CreateFixedBottomMiddleBannerAd("adunit-xxxxxxxxxxxxxxxx", 30, 200);
2124

22-
_bannerAd.OnLoad((res) => {
23-
WX.ShowModal(new ShowModalOption() {
25+
_bannerAd.OnLoad((res) =>
26+
{
27+
WX.ShowModal(new ShowModalOption()
28+
{
2429
content = "BannerAd OnLoad Result:" + JsonUtility.ToJson(res)
2530
});
2631
});
27-
_bannerAd.OnError((res) => {
28-
WX.ShowModal(new ShowModalOption() {
32+
_bannerAd.OnError((res) =>
33+
{
34+
WX.ShowModal(new ShowModalOption()
35+
{
2936
content = "BannerAd onError Result:" + JsonUtility.ToJson(res)
3037
});
3138
});
32-
_bannerAd.OnResize((res) => {
33-
WX.ShowModal(new ShowModalOption() {
39+
_bannerAd.OnResize((res) =>
40+
{
41+
WX.ShowModal(new ShowModalOption()
42+
{
3443
content = "BannerAd onResize Result:" + JsonUtility.ToJson(res)
3544
});
3645
});
3746

38-
WX.ShowToast(new ShowToastOption() {
47+
WX.ShowToast(new ShowToastOption()
48+
{
3949
title = "已创建广告"
4050
});
4151
}
4252

4353
// 切换广告显示状态
44-
private void SwitchAdState() {
45-
if (_isShow) {
54+
private void SwitchAdState()
55+
{
56+
if (_isShow)
57+
{
4658
// 隐藏广告
4759
_bannerAd.Hide();
48-
WX.ShowToast(new ShowToastOption() {
60+
WX.ShowToast(new ShowToastOption()
61+
{
4962
title = "已隐藏广告"
5063
});
51-
} else {
64+
}
65+
else
66+
{
5267
// 展示广告
5368
_bannerAd.Show();
54-
WX.ShowToast(new ShowToastOption() {
69+
WX.ShowToast(new ShowToastOption()
70+
{
5571
title = "已展示广告"
5672
});
5773
}
5874
}
5975

6076
// 销毁广告
61-
private void DestroyAd() {
77+
private void DestroyAd()
78+
{
6279
_bannerAd.Destroy();
63-
WX.ShowToast(new ShowToastOption() {
80+
WX.ShowToast(new ShowToastOption()
81+
{
6482
title = "已销毁广告"
6583
});
6684
}
6785

68-
private void OnDestroy() {
86+
private void OnDestroy()
87+
{
6988
_bannerAd.Destroy();
7089
}
7190
}
Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
using UnityEngine;
22
using WeChatWASM;
33

4-
public class CustomAd : Details {
4+
public class CustomAd : Details
5+
{
56
private WXCustomAd _customAd;
67

78
// SDK未支持CustomAd.IsShow()接口,使用自定义变量记录广告显示状态
89
private bool _isShow;
910

10-
private void Start() {
11+
private void Start()
12+
{
1113
// 绑定按钮事件
1214
GameManager.Instance.detailsController.BindExtraButtonAction(0, SwitchAdState);
1315
GameManager.Instance.detailsController.BindExtraButtonAction(1, DestroyAd);
1416
}
1517

1618
// 创建原生模板广告组件并挂载事件
17-
protected override void TestAPI(string[] args) {
19+
protected override void TestAPI(string[] args)
20+
{
1821
// 创建原生模板广告组件
19-
_customAd = WX.CreateCustomAd(new WXCreateCustomAdParam() {
22+
_customAd = WX.CreateCustomAd(new WXCreateCustomAdParam()
23+
{
2024
// adUnitId 请填写自己的广告位 ID
2125
adUnitId = "adunit-xxxxxxxxxxxxxxxx",
2226
adIntervals = 30,
@@ -25,54 +29,71 @@ protected override void TestAPI(string[] args) {
2529
top = 100,
2630
},
2731
});
28-
_customAd.OnLoad((res) => {
29-
WX.ShowModal(new ShowModalOption() {
32+
_customAd.OnLoad((res) =>
33+
{
34+
WX.ShowModal(new ShowModalOption()
35+
{
3036
content = "CustomAd OnLoad Result:" + JsonUtility.ToJson(res)
3137
});
3238
});
33-
_customAd.OnError((res) => {
34-
WX.ShowModal(new ShowModalOption() {
39+
_customAd.OnError((res) =>
40+
{
41+
WX.ShowModal(new ShowModalOption()
42+
{
3543
content = "CustomAd onError Result:" + JsonUtility.ToJson(res)
3644
});
3745
});
38-
_customAd.OnHide(() => {
39-
WX.ShowModal(new ShowModalOption() {
46+
_customAd.OnHide(() =>
47+
{
48+
WX.ShowModal(new ShowModalOption()
49+
{
4050
content = "CustomAd onHide"
4151
});
4252
});
43-
_customAd.OnClose(() => {
44-
WX.ShowModal(new ShowModalOption() {
53+
_customAd.OnClose(() =>
54+
{
55+
WX.ShowModal(new ShowModalOption()
56+
{
4557
content = "CustomAd onClose"
4658
});
4759
});
4860
}
4961

5062
// 切换广告显示状态
51-
private void SwitchAdState() {
52-
if (_isShow) {
63+
private void SwitchAdState()
64+
{
65+
if (_isShow)
66+
{
5367
// 隐藏广告
5468
_customAd.Hide();
55-
WX.ShowToast(new ShowToastOption() {
69+
WX.ShowToast(new ShowToastOption()
70+
{
5671
title = "已隐藏广告"
5772
});
58-
} else {
73+
}
74+
else
75+
{
5976
// 展示广告
6077
_customAd.Show();
61-
WX.ShowToast(new ShowToastOption() {
78+
WX.ShowToast(new ShowToastOption()
79+
{
6280
title = "已展示广告"
6381
});
6482
}
6583
}
6684

6785
// 销毁广告
68-
private void DestroyAd() {
86+
private void DestroyAd()
87+
{
6988
_customAd.Destroy();
70-
WX.ShowToast(new ShowToastOption() {
89+
WX.ShowToast(new ShowToastOption()
90+
{
7191
title = "已销毁广告"
7292
});
7393
}
7494

75-
private void OnDestroy() {
95+
private void OnDestroy()
96+
{
7697
_customAd.Destroy();
7798
}
7899
}

0 commit comments

Comments
 (0)