Setting up several rewarded video Ads

Hi,

I am sorry if I am being repetitive, but I tried to find solution for the problem I am having and nothing until now.
This is my first game and I am working on it for 5 months now.
I recently implemented ads by following Awesome Tuts tutorial

It worked fine but I am having trouble trying to configure several rewardedvideos behavior…I checked about placements, tried to create several placements in Dashboard but no good.

I am using the code provided in Unity guide…I want the three following rewards:

  • Button on home page to watch ad for coins;
  • Pay coins, watch ad and revive on first death;
  • If you die in second level, you can watch ad to skip the first level and go to second again.

I created three separeted AdManagers gameobjects, 3 differente scripts, but somehow the behaviors seems to be overlapping.
How should I really work with the different rewards?

public class Ads : MonoBehaviour, IUnityAdsListener
{

    string GooglePlay_ID = "XXXXXX";
    bool testMode = true;
    string myPlacementId = "rewardedVideo";
    [SerializeField]
    private UIManager _uiManager;
    // Start is called before the first frame update
    void Start()
    {
        _uiManager = GameObject.Find("Canvas").GetComponent<UIManager>();
        Advertisement.AddListener (this);
        Advertisement.Initialize(GooglePlay_ID, testMode);
    }
    public void DisplayInterstitialAd()
    {
        Advertisement.Show();
    }
    public void DisplayVideoAd()
    {
        Advertisement.Show(myPlacementId);
    }
    public void ShowRewardedVideo() {
        // Check if UnityAds ready before calling Show method:
        if (Advertisement.IsReady(myPlacementId)) {
            Advertisement.Show(myPlacementId);
        }
        else {
            Debug.Log("Rewarded video is not ready at the moment! Please try again later!");
        }
    }

    // Implement IUnityAdsListener interface methods:
    public void OnUnityAdsDidFinish (string placementId, ShowResult showResult) {
        // Define conditional logic for each ad completion status:
        if (showResult == ShowResult.Finished)
        {
            _uiManager.gear+=5;
            _uiManager.UpdateGear();
            Advertisement.RemoveListener(this);
        }
        else if (showResult == ShowResult.Skipped)
        {
            Debug.LogWarning ("NO REWARD!");
        }
        else if (showResult == ShowResult.Failed)
        {
            Debug.LogWarning ("The ad did not finish due to an error.");
        }
    }

    public void OnUnityAdsReady (string placementId) {
        // If the ready Placement is rewarded, show the ad:
        if (placementId == myPlacementId) {
            // Optional actions to take when the placement becomes ready(For example, enable the rewarded ads button)
        }
    }

    public void OnUnityAdsDidError (string message) {
        // Log the error.
    }

    public void OnUnityAdsDidStart (string placementId) {
        // Optional actions to take when the end-users triggers an ad.
    }

    // When the object that subscribes to ad events is destroyed, remove the listener:
    public void OnDestroy() {
        Advertisement.RemoveListener(this);
    }

Every component that adds itself to the SDK as a listener will receive events from the SDK. That’s how the code is designed to work.

One thing you could do is call AddListener when you show an ad in that component, and then remove it again during OnUnityAdsDidFinish. This way you will only have one listener registered at a time - to the component that is currently showing an ad.

Thanks a lot for replying.
Sorry but I am very noob.

I was working with 3 different scripts for each behavior, in 3 different GameObjects (AdsManagers).
Should I centralize everything in only 1 script and 1 AdManager and then add the addlistener in the objects that call the DisplayVideoAd() function?

@

What I personally do is that I have only 1 ads listener in the entire game. It has methods to ask to show ads that takes callbacks as parameters (to do stuff once the ads is seen or if something went wrong)

no good yet =(

Hey, sorry for the delay in responding. Yes, centralizing everything sounds like a good idea - it’s actually how I like to arrange things when I implement the SDK. Then you can code the AdManager to keep track of what type of ad is playing and then give the appropriate reward.

I was trying to use the placement id to give different rewards inside of OnUnityAdsDidFinish result finished but not working yet…I really do not know what else to do…

i have the same issues, but mine is that i only have one button for free coin, and the ads said “Rewarded Video is not available at the moment, please try again”… how do i solve this?

@ikkikurogane123

Please create a new thread and provide as much information as possible, including the version of the SDK you are using, your Unity version, and an example of your ad integration code.