The name `Advertisement' does not exist in the current context

When I turn off my internet connection and start the game sometimes I get this error:

“error CS0103: The name `Advertisement’ does not exist in the current context”

In MonoDevelop the “Advertisement” class also turns to red and is unrecognized and after waiting a minute sometimes it turns blue again or I just need to restart Unity and then I can try starting the game again.

I’m using Unity 5.3.5 and built-in Unity Ads.

The code I’m using:

public IEnumerator showAdCoroutine() {
        while (!Advertisement.isInitialized || !Advertisement.IsReady()) {
            yield return new WaitForSeconds (1);
        }
           
        Advertisement.Show();
    }

Thanks for reporting. We will try if we can reproduce here. If it becomes a big problem for you, you can use Unity Ads SDK from asset store instead: https://www.assetstore.unity3d.com/en/#!/content/66123

/Rasmus

1 Like

Thank you, using Unity Ads SDK seem to have fixed the problem.