Issue with loading ads

The ad isn’t loading or continuing when I hit continue. I believe it’s not an issue with my button because the button is disabling.

int complete
UnityEngine.Debug:Log (object)
Addmanager:OnInitializationComplete () (at Assets/Addmanager.cs:48)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()

Error showing Ad Unit rewardedVideo: NOT_READY - Placement rewardedVideo is not ready
UnityEngine.Debug:Log (object)
Addmanager:OnUnityAdsShowFailure (string,UnityEngine.Advertisements.UnityAdsShowError,string) (at Assets/Addmanager.cs:68)
UnityEngine.Advertisements.Utilities.CoroutineExecutor:Update () (at Library/PackageCache/com.unity.ads@4.0.0/Runtime/Advertisement/Utilities/CoroutineExecutor.cs:17)

It looks like you’re trying to show an ad, but the Ads system doesn’t have one ready. Paste in your AdManager.cs and we’ll take a look.

Here is my code.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;

public class Addmanager : MonoBehaviour, IUnityAdsInitializationListener, IUnityAdsLoadListener,IUnityAdsShowListener
{
    [SerializeField] private bool testMode = true;

    private string gameId = "4819927";

    public static Addmanager Instance;

    private GameOVerHandler gameOVerHandler;



    private void Awake()
    {
        if(Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }

        else
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);

            
            Advertisement.Initialize(gameId, testMode, this);
        }

    }


    public void ShowAdd(GameOVerHandler gameOVerHandler)
    {
        this.gameOVerHandler = gameOVerHandler;

        Advertisement.Show("rewardedVideo", this);
    }

    

    public void OnInitializationComplete()
    {
        Debug.Log("int complete");
    }

    public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    {
        Debug.Log("int failed");
    }

    public void OnUnityAdsAdLoaded(string placementId)
    {
        Debug.Log("ad loaded");
    }

    public void OnUnityAdsFailedToLoad(string placementId, UnityAdsLoadError error, string message)
    {
        Debug.Log($"Error loading Ad Unit {placementId}: {error} - {message}");
    }

    public void OnUnityAdsShowFailure(string placementId, UnityAdsShowError error, string message)
    {
        Debug.Log($"Error showing Ad Unit {placementId}: {error} - {message}");
    }

    public void OnUnityAdsShowStart(string placementId)
    {
        Debug.Log("ad show start");
    }

    public void OnUnityAdsShowClick(string placementId)
    {
        Debug.Log("ad show click");
    }

    public void OnUnityAdsShowComplete(string placementId, UnityAdsShowCompletionState unityAdsShowCompletionState)
    {
        switch ( unityAdsShowCompletionState)
        {
            case UnityAdsShowCompletionState.COMPLETED:
                gameOVerHandler.ContinueGame();
                break;
            case UnityAdsShowCompletionState.SKIPPED:
                break;
            case UnityAdsShowCompletionState.UNKNOWN:
                Debug.LogWarning("Add Failed");
                break;
        }
    }
}

So it looks like both messages are from your debugs, and that the system was correctly initialized, but when it went to get the ad with the campaign, it was unable to do so.

The next thing to check is to make sure that your ad string rewardedVideo exactly matches the ad string in your ad setup.

It appears that Unity Ads is requiring explicit loading of an ad before it can be shown (it seemed not to be necessary in older versions, once the systme was initialized, an ad was usually Loaded).
Let’s change OnInitializationComplete() to this:

    public void OnInitializationComplete()
    {
        Debug.Log("Unity Ads initialization complete");
        Advertisement.Load("rewardedVideo", this);
    }

Privacy & Terms