こちらのサイトを参考にコピペでリワード広告を実装しようとしたところ33行目に
error CS0123: No overload for 'HandleRewardedAdFailedToLoad' matches delegate 'EventHandler<AdErrorEventArgs>'
というエラーが発生しました。
今まで見たことないエラーで調べても情報があまり無かったです。
翻訳しても『「HandleRewardedAdFailedToLoad」のオーバーロードがデリゲート「EventHandler <AdErrorEventArgs>」に一致しません』とあるものの、66行目にあるpublic void HandleRewardedAdFailedToLoadにどうすれば一致させればいいのかもわからず手詰まりになっています。
C#
1using UnityEngine.Events; 2using UnityEngine; 3using GoogleMobileAds.Api; 4using GoogleMobileAds.Common; 5using UnityEngine.UI; 6using System; 7using System.Collections.Generic; 8 9 10public class RewardAd : MonoBehaviour 11{ 12 13 private RewardedAd rewardedAd; 14 15 // Start is called before the first frame update 16 void Start() 17 { 18 string adUnitId; 19 #if UNITY_ANDROID 20 adUnitId = "ca-app-pub-3940256099942544/5224354917"; 21 #elif UNITY_IPHONE 22 adUnitId = "ca-app-pub-3940256099942544/1712485313"; 23 #else 24 adUnitId = "unexpected_platform"; 25 #endif 26 27 this.rewardedAd = new RewardedAd(adUnitId); 28 29 30 // Called when an ad request has successfully loaded. 31 this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded; 32 33//下でエラーが出てます 34 // Called when an ad request failed to load. 35 this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad; 36 37 38 // Called when an ad is shown. 39 this.rewardedAd.OnAdOpening += HandleRewardedAdOpening; 40 // Called when an ad request failed to show. 41 this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow; 42 // Called when the user should be rewarded for interacting with the ad. 43 this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward; 44 // Called when the ad is closed. 45 this.rewardedAd.OnAdClosed += HandleRewardedAdClosed; 46 47 48 // Create an empty ad request. 49 AdRequest request = new AdRequest.Builder().Build(); 50 // Load the rewarded ad with the request. 51 this.rewardedAd.LoadAd(request); 52 } 53 54 55 56 private void UserChoseToWatchAd() 57 { 58 if (this.rewardedAd.IsLoaded()) 59 { 60 this.rewardedAd.Show(); 61 } 62 } 63 64 65 public void HandleRewardedAdLoaded(object sender, EventArgs args) 66 { 67 MonoBehaviour.print("HandleRewardedAdLoaded event received"); 68 } 69 70 71 72 public void HandleRewardedAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) 73 { 74 MonoBehaviour.print( 75 "HandleRewardedAdFailedToLoad event received with message: " 76 + args.Message); 77 } 78 79 80 81 public void HandleRewardedAdOpening(object sender, EventArgs args) 82 { 83 MonoBehaviour.print("HandleRewardedAdOpening event received"); 84 } 85 86 public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args) 87 { 88 MonoBehaviour.print( 89 "HandleRewardedAdFailedToShow event received with message: " 90 + args.Message); 91 } 92 93 public void HandleRewardedAdClosed(object sender, EventArgs args) 94 { 95 MonoBehaviour.print("HandleRewardedAdClosed event received"); 96 } 97 98 public void HandleUserEarnedReward(object sender, Reward args) 99 { 100 string type = args.Type; 101 double amount = args.Amount; 102 MonoBehaviour.print( 103 "HandleRewardedAdRewarded event received for " 104 + amount.ToString() + " " + type); 105 } 106 107}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/09/02 10:57
2021/09/02 11:33
退会済みユーザー
2021/09/09 04:04
2021/09/09 06:15
2022/02/06 03:10