'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
Solution 1:[1]
- Go to Window-> Package Manager -> in Project
- Find the Advertisement Package and click "Remove"
- Go to "Packages: Unity Registry" in Package Manager
- find Advertisement Package and install (you'll get V3.7.5)
- restart Unity
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Paul Povel |
Solution 2 | Cubex Technologies |