Show rewarded ad after button click

Hello everyone,

currently I am trying to get a rewarded ad to play after a button click. But after reviewing a couble of tutorials I do not seem to understand how it actually works. And this is made worse because they use different approaches and I cannot follow at all.

All I want is to have this implemented:

  • if button clicked show a rewarded ad
  • if the rewarded ad is shown succesful without any interuptions, give the player a few keys

I am able to use the Button-ClickOn() methods and the reward system also works. The only problem is that I can bring Unity to show the Ad. I am using UnityEngine.Advertisements for it and do not want to use any other stuff like monetaization or such

Can anyone give me a simple solution for this problem?

Thanks in advance.

1 Like

It has to be the rewarded ad with results like finished, failed etc, because after the ad is shown I switch scenes. And currently the close button of the ad always triggers other buttons in the loaded scene. So with the result that the ad is succesfully shown I want to switch scenes only after the advertisement is finished.

1 Like

@i9fasc7

The documentation provides a comprehensive rewarded ads example:
https://docs.unity3d.com/Packages/com.unity.ads@3.2/manual/MonetizationBasicIntegrationUnity.html#rewarded-video-ads

If you have any problems with the example, let me know and I’ll try to clarify it.

I already tried that and always got an error regarding the IUnityAdsListener. But apparently only due to an older version of the ad service. I changed it under Unity->Window->Package Handler to the newest version, but then got about 170 warnings and 10 errors regarding that advertisement and monetization are not compatible etc.
I am going to have to export my assets and try to rebuild the game under a new project, because I cannot fix the current project.

But could you tell me how the public void methods work?
If I read it correctly, the OnUnityAdsReady would have to be called first and afterwards the OnUnityAdsDidFinish.
Then I can use the “showResult == ShowResult.Finished” to create the reward and switch keys.
Am I correct so far?
But how would the second method get the ShowResult.Finished? Or is it automatically set after Advertisement.Show?
And what is the difference between Advertisement.Show() and Advertisement.Show(placementId)?

These are a lot of questions, I know but at the moment I think that the simple Interstitial Ad maybe is the easier solution for my game.
Apparently my problem with the close button being pressed and at the same time buttons in my scene react is only happening in the editor. This should not happen in the finished mobile build, if I researched correctly.

That is the correct order, but you don’t have to call them. They will be called automatically by the Ads SDK when the time is right and it will fill in the correct ShowResult.

I have a question too about rewarded ads . In other games when I click on a button so I can be rewarded the ads always show up but in my game when the player click on the button to watch the ad so he can be rewarded it only shows one time and then after playing and he want to click on the ad an other time the rewarded ads doesn’t show up why ? How I can fix that .

1 Like