This article is a troubleshooting to a well-known error that appears while using Unity Ads – The name Advertisement does not exist in the current context.
The solution is incredibly simple!
This error appears because you didn’t set up Advertisements support for you project. There’s a special tab in Unity editor called Services. There is a bunch of settings. Among them – Advertisements support.
You should know, that before you use Unity Ads, you should register an account there. If you do not have a published application, specify it in a corresponding field.
Fixing “The name Advertisement does not exist in the current context”
There are 3 simple steps to begin working with Unity Ads:
Go to Services tab (Window – Services) and enter your personal data – developer id and project’s name:
Then click Link button and you will se the list of Unity Services. Now enable the support for Unity Ads service by clicking on the “Ads” section and then switching the trigger on the Ads settings:
And the last step. If you want to test the advertisements inside of the editor, don’t forget to specify this option:
This one provides a possibility to show a sub ad while testing your app in the editor.
When you’re done with all that your code will compile and you will not get the error “Advertisement does not exist in the current context” anymore.