From 92014ede71971ce8d947edea1e83be2a573e1d09 Mon Sep 17 00:00:00 2001 From: v_shanxia Date: Fri, 18 Apr 2025 09:48:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=B9=BF=E5=91=8Ashow=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API_V2/Assets/API/Ad/BannerAd/BannerAd.cs | 15 ++++++++++-- .../API_V2/Assets/API/Ad/CustomAd/CustomAd.cs | 15 ++++++++++-- .../API/Ad/InterstitalAd/InterstitalAd.cs | 22 +++++++++++++---- .../API/Ad/RewardedVideoAd/RewardedVideoAd.cs | 24 ++++++++++++++++--- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/Demo/API_V2/Assets/API/Ad/BannerAd/BannerAd.cs b/Demo/API_V2/Assets/API/Ad/BannerAd/BannerAd.cs index d74f07f11..4fbb9ba23 100644 --- a/Demo/API_V2/Assets/API/Ad/BannerAd/BannerAd.cs +++ b/Demo/API_V2/Assets/API/Ad/BannerAd/BannerAd.cs @@ -1,3 +1,4 @@ +using System; using UnityEngine; using WeChatWASM; @@ -71,11 +72,21 @@ private void SwitchAdState() else { // 展示广告 - _bannerAd.Show(); - WX.ShowToast(new ShowToastOption() { title = "已展示广告" }); + _bannerAd.Show(ShowSuccess, ShowFail); } } + private Action ShowSuccess = (res) => + { + WX.ShowModal(new ShowModalOption() { content = "BannerAd Show Success:" + JsonUtility.ToJson(res) }); + }; + + + private Action ShowFail = (res) => + { + WX.ShowModal(new ShowModalOption() { content = "BannerAd Show Fail:" + JsonUtility.ToJson(res) }); + }; + // 销毁广告 private void DestroyAd() { diff --git a/Demo/API_V2/Assets/API/Ad/CustomAd/CustomAd.cs b/Demo/API_V2/Assets/API/Ad/CustomAd/CustomAd.cs index 125be8750..4f3d8eada 100644 --- a/Demo/API_V2/Assets/API/Ad/CustomAd/CustomAd.cs +++ b/Demo/API_V2/Assets/API/Ad/CustomAd/CustomAd.cs @@ -1,3 +1,4 @@ +using System; using UnityEngine; using WeChatWASM; @@ -72,11 +73,21 @@ private void SwitchAdState() else { // 展示广告 - _customAd.Show(); - WX.ShowToast(new ShowToastOption() { title = "已展示广告" }); + _customAd.Show(ShowSuccess, ShowFail); } } + private Action ShowSuccess = (res) => + { + WX.ShowModal(new ShowModalOption() { content = "CustomAd Show Success:" + JsonUtility.ToJson(res) }); + }; + + + private Action ShowFail = (res) => + { + WX.ShowModal(new ShowModalOption() { content = "CustomAd Show Fail:" + JsonUtility.ToJson(res) }); + }; + // 销毁广告 private void DestroyAd() { diff --git a/Demo/API_V2/Assets/API/Ad/InterstitalAd/InterstitalAd.cs b/Demo/API_V2/Assets/API/Ad/InterstitalAd/InterstitalAd.cs index 47434157d..bdc13fd83 100644 --- a/Demo/API_V2/Assets/API/Ad/InterstitalAd/InterstitalAd.cs +++ b/Demo/API_V2/Assets/API/Ad/InterstitalAd/InterstitalAd.cs @@ -1,3 +1,4 @@ +using System; using UnityEngine; using WeChatWASM; @@ -30,7 +31,7 @@ protected override void TestAPI(string[] args) WX.ShowModal( new ShowModalOption() { - content = "RewardedVideoAd OnLoad Result:" + JsonUtility.ToJson(res) + content = "InterstitialAd OnLoad Result:" + JsonUtility.ToJson(res) } ); } @@ -41,14 +42,14 @@ protected override void TestAPI(string[] args) WX.ShowModal( new ShowModalOption() { - content = "RewardedVideoAd onError Result:" + JsonUtility.ToJson(res) + content = "InterstitialAd onError Result:" + JsonUtility.ToJson(res) } ); } ); _interstitialAd.OnClose(() => { - WX.ShowModal(new ShowModalOption() { content = "RewardedVideoAd onClose" }); + WX.ShowModal(new ShowModalOption() { content = "InterstitialAd onClose" }); }); // 预加载广告 _interstitialAd.Load(); @@ -59,10 +60,21 @@ protected override void TestAPI(string[] args) // 展示广告 private void ShowAd() { - _interstitialAd.Show(); - WX.ShowToast(new ShowToastOption() { title = "已展示广告" }); + _interstitialAd.Show(ShowSuccess, ShowFail); } + private Action ShowSuccess = (res) => + { + WX.ShowModal(new ShowModalOption() { content = "InterstitialAd Show Success:" + JsonUtility.ToJson(res) }); + }; + + + private Action ShowFail = (res) => + { + WX.ShowModal(new ShowModalOption() { content = "InterstitialAd Show Fail:" + JsonUtility.ToJson(res) }); + }; + + // 销毁广告 private void DestroyAd() { diff --git a/Demo/API_V2/Assets/API/Ad/RewardedVideoAd/RewardedVideoAd.cs b/Demo/API_V2/Assets/API/Ad/RewardedVideoAd/RewardedVideoAd.cs index 4191d8731..377e97030 100644 --- a/Demo/API_V2/Assets/API/Ad/RewardedVideoAd/RewardedVideoAd.cs +++ b/Demo/API_V2/Assets/API/Ad/RewardedVideoAd/RewardedVideoAd.cs @@ -1,3 +1,4 @@ +using System; using UnityEngine; using WeChatWASM; @@ -64,12 +65,29 @@ protected override void TestAPI(string[] args) } // 展示广告 - private void ShowAd() + // private void ShowAd() + // { + // _rewardedVideoAd.Show(); + // WX.ShowToast(new ShowToastOption() { title = "已展示广告" }); + // } + + + private void ShowAd() { - _rewardedVideoAd.Show(); - WX.ShowToast(new ShowToastOption() { title = "已展示广告" }); + _rewardedVideoAd.Show(ShowSuccess, ShowFail); } + private Action ShowSuccess = (res) => + { + WX.ShowModal(new ShowModalOption() { content = "RewardedVideoAd Show Success:" + JsonUtility.ToJson(res) }); + }; + + + private Action ShowFail = (res) => + { + WX.ShowModal(new ShowModalOption() { content = "RewardedVideoAd Show Fail:" + JsonUtility.ToJson(res) }); + }; + // 销毁广告 private void DestroyAd() {