Leo Doyle
Leo Doyle

Reputation: 11

Unity Ads "Advertisement does not contain definition for IsReady"

So I'm trying to implement unity ads into my game, but it throws the error Assets/Scripts/UnityAds.cs(23,28): error CS0117: 'Advertisement' does not contain a definition for 'IsReady' and Assets/Scripts/UnityAds.cs(18,23): error CS1501: No overload for method 'Show' takes 0 arguments

Here's the code of UnityAds.cs:

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

public class UnityAds : MonoBehaviour
{

  public string GooglePlay_ID = "#######";
  public string placementID = "standardBanner";
  public bool TestMode = true;

    // Start is called before the first frame update
    void Start()
    {
        Advertisement.Initialize(GooglePlay_ID, TestMode);
        StartCoroutine(ShowBannerWhenReady());
        Advertisement.Show();
    }


    IEnumerator ShowBannerWhenReady(){
      while(!Advertisement.IsReady(placementID)){
        yield return new WaitForSeconds(0.5f);
      }
      Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
      Advertisement.Banner.Show(placementID);


    }

    // Update is called once per frame
    void Update()
    {

    }
}

Any idea what could be causing this issue? I've already updated to the most recent version of UnityAds(And yes, I have the google play Id correct, I just didn't want to share that publicly

Upvotes: 1

Views: 6362

Answers (4)

NeoTech
NeoTech

Reputation: 21

Maybe you already saw, that Google asks you to update UnityAds to 4.0.1. In that case, you can't downgrade to 3.7.5. I found a solution for it. As I understood, new versions of UnityAds don't use IsReady();. So one thing for you to do is to correct your code like that:

Before:

if (Advertisement.IsReady)
        {
            Advertisement.Show("NameOfYourPlacement");
        }

After:

Advertisement.Show("NameOfYourPlacement");

I hope it helped for you, have a nice day!

Upvotes: 0

Daniel Pernia
Daniel Pernia

Reputation: 31

I had a similar problem, but with unity cloud build, updating from 2019.4 to 2021.3.

Solution:

  • Open PlayerSetting
  • select services -> Ads
  • turn on ads
  • update version 3.75 -> 4.2

There is probably an error in cloud build where they use the most recent version instead of the one selected in the project.

enter image description here

Upvotes: 0

Paul Povel
Paul Povel

Reputation: 11

  1. Go to Window-> Package Manager -> in Project
  2. Find the Advertisement Package and click "Remove"
  3. Go to "Packages: Unity Registry" in Package Manager
  4. find Advertisement Package and install (you'll get V3.7.5)
  5. restart Unity

Upvotes: 1

Cubex Technologies
Cubex Technologies

Reputation: 19

I had the same problem. You can use SDK version 3.75 . It worked for me. for the second error remove Advertisement.Show() from void Start function.

Upvotes: 0

Related Questions