I have had no issues with Unity test ads, they were displaying fine with no errors on the Android build.
But then as I was nearing release, I turned "test mode" off ads in the editor and now all my references to Advertisement in my code suddenly don't exist in the current context.
Error:
Assets\Scripts\AdManager.cs(32,21): error CS0103: The name 'Advertisement' does not exist in the current context
I haven't found anything online about this and I'm really confused. Have tried the "turn ads off, reopen unity, turn ads on" but it didn't get rid of the error.
Here's my code:
using UnityEngine;
using UnityEngine.Advertisements;
public class AdManager : MonoBehaviour
{
public void ShowAd(int roundScore){
Debug.Log("Recieved request to display an ad");
Debug.Log(roundScore);
if(roundScore >= 40){
Debug.Log("Trying to show an ad because score is larger than 40");
// Check for ad + show it
if(Advertisement.IsReady("video")){
Advertisement.Show("video");
}
}else{
Debug.Log("Trying to show a random ad");
if(Random.Range(0, 7) == 4){
Debug.Log("Random ad will be shown if ready");
//Check for ad + show it
if(Advertisement.IsReady("video")){
Debug.Log("An ad was ready so it is being shown");
Advertisement.Show("video");
}
}
}
}
}
Thanks for the help.