Reputation: 11
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
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
Reputation: 31
I had a similar problem, but with unity cloud build, updating from 2019.4 to 2021.3.
Solution:
There is probably an error in cloud build where they use the most recent version instead of the one selected in the project.
Upvotes: 0
Reputation: 11
Upvotes: 1
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