Skip to content

Commit ab4d05a

Browse files
authored
Merge pull request #836 from wechat-miniprogram/dotnet-version
增加npm run format指令,自动格式化全部文件
2 parents 4061998 + b2023d3 commit ab4d05a

File tree

668 files changed

+123931
-78317
lines changed

Some content is hidden

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

668 files changed

+123931
-78317
lines changed

.config/dotnet-tools.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"csharpier": {
6+
"version": "0.28.2",
7+
"commands": [
8+
"dotnet-csharpier"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

.editorconfig

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Remove the line below if you want to inherit .editorconfig settings from higher directories
2+
root = true
3+
4+
#### Core EditorConfig Options ####
5+
6+
[*]
7+
# Indentation and spacing: https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties
8+
indent_style = space
9+
indent_size = 4
10+
end_of_line = crlf
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = false
14+
15+
# C# files
16+
[*.cs]
17+
# 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 = all
19+
csharp_new_line_before_else = true
20+
csharp_new_line_before_catch = true
21+
csharp_new_line_before_finally = true
22+
csharp_new_line_before_members_in_object_initializers = true
23+
csharp_new_line_before_members_in_anonymous_types = true
24+
csharp_new_line_between_query_expression_clauses = true
25+
26+
#### .NET Coding Conventions ####
27+
28+
# this. and Me. preferences
29+
dotnet_style_qualification_for_method = true
30+
31+
#### Diagnostic configuration ####
32+
33+
# CA1000: Do not declare static members on generic types
34+
dotnet_diagnostic.CA1000.severity = warning

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

+41-30
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
using UnityEngine;
2-
using WeChatWASM;
3-
using UnityEngine.UI;
4-
using UnityEngine.Networking;
51
using System;
62
using System.Collections;
73
using System.Collections.Generic;
8-
4+
using UnityEngine;
95
using UnityEngine.Audio;
106
using UnityEngine.Networking;
7+
using UnityEngine.Networking;
8+
using UnityEngine.UI;
9+
using WeChatWASM;
1110

1211
public class AdWithAudio : Details
1312
{
14-
1513
private WXRewardedVideoAd _rewardedVideoAd;
1614
public AudioSource audioSource;
1715
public AudioClip audioClipCDN;
18-
16+
1917
private void Start()
2018
{
2119
StartCoroutine(LoadCDNAudio());
2220

23-
2421
// 创建激励视频广告组件
25-
_rewardedVideoAd = WX.CreateRewardedVideoAd(new WXCreateRewardedVideoAdParam()
22+
_rewardedVideoAd = WX.CreateRewardedVideoAd(
23+
new WXCreateRewardedVideoAdParam()
24+
{
25+
// adUnitId 请填写自己的广告位 ID
26+
adUnitId = "adunit-881d549c5a14a7e3"
27+
}
28+
);
29+
30+
_rewardedVideoAd.OnError(err =>
2631
{
27-
// adUnitId 请填写自己的广告位 ID
28-
adUnitId = "adunit-881d549c5a14a7e3"
29-
});
30-
31-
_rewardedVideoAd.OnError(err => {
3232
Debug.Log(JsonUtility.ToJson(err));
3333
});
34-
34+
3535
GameManager.Instance.detailsController.BindExtraButtonAction(0, PlayCDN);
3636
}
3737

@@ -49,7 +49,8 @@ IEnumerator LoadCDNAudio()
4949
// 添加 AudioSource 组件
5050
audioSource = newGameObject.AddComponent<AudioSource>();
5151

52-
string uriString = "https://res.wx.qq.com/wechatgame/product/webpack/userupload/20220901/211827/CallMeTeenTop.mp3";
52+
string uriString =
53+
"https://res.wx.qq.com/wechatgame/product/webpack/userupload/20220901/211827/CallMeTeenTop.mp3";
5354
Uri uri = new Uri(uriString);
5455
UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(uri, AudioType.MPEG);
5556
yield return request.SendWebRequest();
@@ -78,25 +79,35 @@ public void PlayCDN()
7879
// 展示广告
7980
private void ShowAd()
8081
{
81-
_rewardedVideoAd.Show(res => {
82-
Debug.Log("Show success");
83-
Debug.Log(JsonUtility.ToJson(res));
84-
}, err => {
85-
Debug.Log(JsonUtility.ToJson(err));
86-
_rewardedVideoAd.Load(res => {
87-
Debug.Log("load success");
88-
_rewardedVideoAd.Show();
89-
}, err => {
90-
Debug.Log("load fail");
82+
_rewardedVideoAd.Show(
83+
res =>
84+
{
85+
Debug.Log("Show success");
86+
Debug.Log(JsonUtility.ToJson(res));
87+
},
88+
err =>
89+
{
9190
Debug.Log(JsonUtility.ToJson(err));
92-
});
93-
});
91+
_rewardedVideoAd.Load(
92+
res =>
93+
{
94+
Debug.Log("load success");
95+
_rewardedVideoAd.Show();
96+
},
97+
err =>
98+
{
99+
Debug.Log("load fail");
100+
Debug.Log(JsonUtility.ToJson(err));
101+
}
102+
);
103+
}
104+
);
94105
}
95-
96106

97107
public void Destroy()
98108
{
99-
if (audioSource != null) {
109+
if (audioSource != null)
110+
{
100111
audioSource.clip = null;
101112
audioSource = null;
102113
}

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

+39-39
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
using UnityEngine;
1+
using UnityEngine;
22
using WeChatWASM;
33

44
public class BannerAd : Details
55
{
66
private WXBannerAd _bannerAd;
7-
7+
88
private bool _isShow = false;
9-
9+
1010
private void Start()
1111
{
1212
// 绑定按钮事件
@@ -21,33 +21,42 @@ protected override void TestAPI(string[] args)
2121
// adUnitId 请填写自己的广告位 ID
2222
// 创建预设的 Banner 广告
2323
_bannerAd = WX.CreateFixedBottomMiddleBannerAd("adunit-xxxxxxxxxxxxxxxx", 30, 200);
24-
25-
_bannerAd.OnLoad((res) =>
26-
{
27-
WX.ShowModal(new ShowModalOption()
24+
25+
_bannerAd.OnLoad(
26+
(res) =>
2827
{
29-
content = "BannerAd OnLoad Result:" + JsonUtility.ToJson(res)
30-
});
31-
});
32-
_bannerAd.OnError((res) =>
33-
{
34-
WX.ShowModal(new ShowModalOption()
28+
WX.ShowModal(
29+
new ShowModalOption()
30+
{
31+
content = "BannerAd OnLoad Result:" + JsonUtility.ToJson(res)
32+
}
33+
);
34+
}
35+
);
36+
_bannerAd.OnError(
37+
(res) =>
3538
{
36-
content = "BannerAd onError Result:" + JsonUtility.ToJson(res)
37-
});
38-
});
39-
_bannerAd.OnResize((res) =>
40-
{
41-
WX.ShowModal(new ShowModalOption()
39+
WX.ShowModal(
40+
new ShowModalOption()
41+
{
42+
content = "BannerAd onError Result:" + JsonUtility.ToJson(res)
43+
}
44+
);
45+
}
46+
);
47+
_bannerAd.OnResize(
48+
(res) =>
4249
{
43-
content = "BannerAd onResize Result:" + JsonUtility.ToJson(res)
44-
});
45-
});
46-
47-
WX.ShowToast(new ShowToastOption()
48-
{
49-
title = "已创建广告"
50-
});
50+
WX.ShowModal(
51+
new ShowModalOption()
52+
{
53+
content = "BannerAd onResize Result:" + JsonUtility.ToJson(res)
54+
}
55+
);
56+
}
57+
);
58+
59+
WX.ShowToast(new ShowToastOption() { title = "已创建广告" });
5160
}
5261

5362
// 切换广告显示状态
@@ -57,30 +66,21 @@ private void SwitchAdState()
5766
{
5867
// 隐藏广告
5968
_bannerAd.Hide();
60-
WX.ShowToast(new ShowToastOption()
61-
{
62-
title = "已隐藏广告"
63-
});
69+
WX.ShowToast(new ShowToastOption() { title = "已隐藏广告" });
6470
}
6571
else
6672
{
6773
// 展示广告
6874
_bannerAd.Show();
69-
WX.ShowToast(new ShowToastOption()
70-
{
71-
title = "已展示广告"
72-
});
75+
WX.ShowToast(new ShowToastOption() { title = "已展示广告" });
7376
}
7477
}
7578

7679
// 销毁广告
7780
private void DestroyAd()
7881
{
7982
_bannerAd.Destroy();
80-
WX.ShowToast(new ShowToastOption()
81-
{
82-
title = "已销毁广告"
83-
});
83+
WX.ShowToast(new ShowToastOption() { title = "已销毁广告" });
8484
}
8585

8686
private void OnDestroy()

0 commit comments

Comments
 (0)