File tree 4 files changed +64
-12
lines changed
Demo/API_V2/Assets/API/Ad
4 files changed +64
-12
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using UnityEngine ;
2
3
using WeChatWASM ;
3
4
@@ -71,11 +72,21 @@ private void SwitchAdState()
71
72
else
72
73
{
73
74
// 展示广告
74
- _bannerAd . Show ( ) ;
75
- WX . ShowToast ( new ShowToastOption ( ) { title = "已展示广告" } ) ;
75
+ _bannerAd . Show ( ShowSuccess , ShowFail ) ;
76
76
}
77
77
}
78
78
79
+ private Action < WXTextResponse > ShowSuccess = ( res ) =>
80
+ {
81
+ WX . ShowModal ( new ShowModalOption ( ) { content = "BannerAd Show Success:" + JsonUtility . ToJson ( res ) } ) ;
82
+ } ;
83
+
84
+
85
+ private Action < WXTextResponse > ShowFail = ( res ) =>
86
+ {
87
+ WX . ShowModal ( new ShowModalOption ( ) { content = "BannerAd Show Fail:" + JsonUtility . ToJson ( res ) } ) ;
88
+ } ;
89
+
79
90
// 销毁广告
80
91
private void DestroyAd ( )
81
92
{
Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using UnityEngine ;
2
3
using WeChatWASM ;
3
4
@@ -72,11 +73,21 @@ private void SwitchAdState()
72
73
else
73
74
{
74
75
// 展示广告
75
- _customAd . Show ( ) ;
76
- WX . ShowToast ( new ShowToastOption ( ) { title = "已展示广告" } ) ;
76
+ _customAd . Show ( ShowSuccess , ShowFail ) ;
77
77
}
78
78
}
79
79
80
+ private Action < WXTextResponse > ShowSuccess = ( res ) =>
81
+ {
82
+ WX . ShowModal ( new ShowModalOption ( ) { content = "CustomAd Show Success:" + JsonUtility . ToJson ( res ) } ) ;
83
+ } ;
84
+
85
+
86
+ private Action < WXTextResponse > ShowFail = ( res ) =>
87
+ {
88
+ WX . ShowModal ( new ShowModalOption ( ) { content = "CustomAd Show Fail:" + JsonUtility . ToJson ( res ) } ) ;
89
+ } ;
90
+
80
91
// 销毁广告
81
92
private void DestroyAd ( )
82
93
{
Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using UnityEngine ;
2
3
using WeChatWASM ;
3
4
@@ -30,7 +31,7 @@ protected override void TestAPI(string[] args)
30
31
WX . ShowModal (
31
32
new ShowModalOption ( )
32
33
{
33
- content = "RewardedVideoAd OnLoad Result:" + JsonUtility . ToJson ( res )
34
+ content = "InterstitialAd OnLoad Result:" + JsonUtility . ToJson ( res )
34
35
}
35
36
) ;
36
37
}
@@ -41,14 +42,14 @@ protected override void TestAPI(string[] args)
41
42
WX . ShowModal (
42
43
new ShowModalOption ( )
43
44
{
44
- content = "RewardedVideoAd onError Result:" + JsonUtility . ToJson ( res )
45
+ content = "InterstitialAd onError Result:" + JsonUtility . ToJson ( res )
45
46
}
46
47
) ;
47
48
}
48
49
) ;
49
50
_interstitialAd . OnClose ( ( ) =>
50
51
{
51
- WX . ShowModal ( new ShowModalOption ( ) { content = "RewardedVideoAd onClose" } ) ;
52
+ WX . ShowModal ( new ShowModalOption ( ) { content = "InterstitialAd onClose" } ) ;
52
53
} ) ;
53
54
// 预加载广告
54
55
_interstitialAd . Load ( ) ;
@@ -59,10 +60,21 @@ protected override void TestAPI(string[] args)
59
60
// 展示广告
60
61
private void ShowAd ( )
61
62
{
62
- _interstitialAd . Show ( ) ;
63
- WX . ShowToast ( new ShowToastOption ( ) { title = "已展示广告" } ) ;
63
+ _interstitialAd . Show ( ShowSuccess , ShowFail ) ;
64
64
}
65
65
66
+ private Action < WXTextResponse > ShowSuccess = ( res ) =>
67
+ {
68
+ WX . ShowModal ( new ShowModalOption ( ) { content = "InterstitialAd Show Success:" + JsonUtility . ToJson ( res ) } ) ;
69
+ } ;
70
+
71
+
72
+ private Action < WXTextResponse > ShowFail = ( res ) =>
73
+ {
74
+ WX . ShowModal ( new ShowModalOption ( ) { content = "InterstitialAd Show Fail:" + JsonUtility . ToJson ( res ) } ) ;
75
+ } ;
76
+
77
+
66
78
// 销毁广告
67
79
private void DestroyAd ( )
68
80
{
Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using UnityEngine ;
2
3
using WeChatWASM ;
3
4
@@ -64,12 +65,29 @@ protected override void TestAPI(string[] args)
64
65
}
65
66
66
67
// 展示广告
67
- private void ShowAd ( )
68
+ // private void ShowAd()
69
+ // {
70
+ // _rewardedVideoAd.Show();
71
+ // WX.ShowToast(new ShowToastOption() { title = "已展示广告" });
72
+ // }
73
+
74
+
75
+ private void ShowAd ( )
68
76
{
69
- _rewardedVideoAd . Show ( ) ;
70
- WX . ShowToast ( new ShowToastOption ( ) { title = "已展示广告" } ) ;
77
+ _rewardedVideoAd . Show ( ShowSuccess , ShowFail ) ;
71
78
}
72
79
80
+ private Action < WXTextResponse > ShowSuccess = ( res ) =>
81
+ {
82
+ WX . ShowModal ( new ShowModalOption ( ) { content = "RewardedVideoAd Show Success:" + JsonUtility . ToJson ( res ) } ) ;
83
+ } ;
84
+
85
+
86
+ private Action < WXTextResponse > ShowFail = ( res ) =>
87
+ {
88
+ WX . ShowModal ( new ShowModalOption ( ) { content = "RewardedVideoAd Show Fail:" + JsonUtility . ToJson ( res ) } ) ;
89
+ } ;
90
+
73
91
// 销毁广告
74
92
private void DestroyAd ( )
75
93
{
You can’t perform that action at this time.
0 commit comments