- Home /
Google Admob - two different rewarded ads
I'm implementing reward based video ads in my game using Google Admob. There are two functions that provide the reward. One is a ReceiveLife() function where once the player dies, if they click on the revive button the game restarts and the score is set to score before the player dies instead of 0. The other function is ReceivePoints(), where if the player clicks on the add points button, they are rewarded with 100 extra points. I looked at the documentation provided in google admob regarding loading multiple rewarded ads, but I'm unsure of how to go about calling these two functions in the "HandleRewardedAdClosed" function. Here is the code that works for only function (ReceiveLife()):
public class AdScript : MonoBehaviour
{
string Video_Ad_Id = "ca-app-pub-3940256099942544/5224354917";
private RewardedAd rewardedAd;
void Start()
{
MobileAds.Initialize(initStatus => { });
RequestRewardBasedVideo();
}
public void RequestRewardBasedVideo()
{
this.rewardedAd = new RewardedAd(Video_Ad_Id);
this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
this.rewardedAd.OnAdOpening += HandleRewardedAdOpening;
this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
this.rewardedAd.OnAdClosed += HandleRewardedAdClosed;
AdRequest request = new AdRequest.Builder().Build();
this.rewardedAd.LoadAd(request);
}
public void ShowVideoRewardAd()
{
if (this.rewardedAd.IsLoaded())
{
this.rewardedAd.Show();
}
}
.
.
.
.
public void HandleRewardedAdClosed(object sender, EventArgs args)
{
this.RequestRewardBasedVideo();
}
public void HandleUserEarnedReward(object sender, Reward args)
{
GameManager.instance.ReceiveLife();
}
How do I call two rewarded functions in the HandleUserEarnedReward() function above. Can someone please help?
Answer by Talmagett · Feb 08, 2021 at 04:28 PM
RewardedAd and RewardBasedVideo different types, i suggest to watch video about this
Your answer
![](https://koobas.hobune.stream/wayback/20220613011443im_/https://answers.unity.com/themes/thub/images/avi.jpg)