Problems with the IUnityAdsListener and AdListener component

Hello, I was working through the mobile course, and noticed that I have certain errors, and I am assuming that they have something to do with my Ads package

The errors are that the IUnityAdsListener is highlighted(about the 5th line down), and the Adlistener part is highlighted too

I am assuming this is because of my ads package because All I have in my package manager is the Advertisements Legacy, and the Advertisements Mediation…

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

public class AdManager : MonoBehaviour, IUnityAdsListener
{
[SerializeField] private bool testMode = true;
public static AdManager Instance;
private GameOverHandler gameOverHandler;

#if UNITY_ANDROID
private string gameId = “5216947”;
#elif UNITY_IOS
private string gameId = “5216946”;
#endif

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

    else
    {
        Instance = this;
        DontDestroyOnLoad(gameObject);

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

public void ShowAd(GameOverHandler gameOverHandler)
{
    this.gameOverHandler = gameOverHandler;
    Advertisement.Show("rewardedVideo");
}

public void OnUnityAdsDidError(string message)
{
    Debug.LogError($"Unity Ads Error{message}");
}

public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
{
    switch(showResult)
    {
        case ShowResult.Finished:
            gameOverHandler.ContinueGame();
            break;

        case ShowResult.Skipped:
            //Ad was skipped
            break;

        case ShowResult.Failed:
            Debug.LogWarning("Ad Failed");
            break;
    }
}

public void OnUnityAdsDidStart(string placementId)
{
    Debug.Log("Ads Started");
}

public void OnUnityAdsReady(string placementId)
{
    Debug.Log("Unity Ads Ready");
}

}

The AdListener Error is

Advertisement.AdListener(this);

It is inside of the first else statement

You’re not specifying what the error is but I suspect this post will help

Thanks for the response,

Assets\Scripts\AdsManager.cs(6,41): error CS0246: The type or namespace name ‘IUnityAdsListener’ could not be found (are you missing a using directive or an assembly reference?)

That would be the error, however I am currently trying to mess around with editor versions because I am using the newest versions of the Advertisements with Unity 2021

I think I am just gonna scrap the game because went I went back into the editor, none of the scripts are compiling, and the materials are off, I will take the time to learn more about development before venturing into advanced topics where right now , Instantiation is my limit… I don’t know which post to mark as solved, so ill just do this one so that the topic will close sooner.

Sorry for the time wasting,
-Chris

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms