Hey I’m trying to get unity ads to work in my new project I’m getting:
Assets/Game.cs(5,19): error CS0234: The type or namespace name Advertisements' does not exist in the namespace UnityEngine’. Are you missing an assembly reference?
I have ads enabled and the build in extension it worked fine in my last project.
UNITY_ADS is for convenience (at least that was the intention). With Ads SDK package from asset store, you would still need to use e.g. UNITY_IPHONE and/or UNITY_ANDROID conditionals in your code, if shipping for other platforms.
With the Asset Store version I was able to build for Windows UWP without the need for UNITY_ADS, or UNITY_IPHONE, etc. Which made my code much cleaner. Now I had to refactor my code with a bunch of ugly #if UNITY_ADS after switching to the internal version.
Ok, you are right. However the reason for this has been concerns about binary sizes, for which reason Ads SDK is only included in builds for Android and iOS.
Remember you can still use the Ads SDK from asset store if you like. Although sounds like you have refactored your code now anyways.
Did you experience this yourself, or is it based on other reports on the forum? We have shipped own games with the integrated Ads SDK to TestFlight and haven’t experienced the mentioned problems.
Does that mean that it worked in the editor, i.e. you got the “Here would be your ad” placeholder? How about when you deploy to local device for testing?
I had replaced it, however I just went back to the internal Unity Ads and pushed a new build using TestMode to the iOS TestFlight. It once again repros the issue. I.e. Unity Ads is initialized, but none are available.
I just created a Beta App Review request and added unityads-support@unity3d.com as a tester. Hopefully it gets approved.
I am having the same issue as the original poster: my game was actually working perfectly in 5.5.0, with ads being called as expected, and then out of nowhere I got the “Advertisements namespace does not exist” error.
I was using UNITY_ANDROID in my scripts and after checking this thread I modified them with UNITY_ADS instead. Anyway, all code within is actually greyed (with Android target platform selected for the build, of course) and it is not called at all when the game runs on my phone. It is like the #if directive isn’t recognised at all.
I just upgraded to 5.5.1 (on Win 10) and no difference.
Any suggestion?
Thanks!!
EDIT: found the issue: somehow the “Enable builtin ads extension” in the advanced settings got unchecked!
If you are only targeting Android you should be fine. However if you are also targeting iOS then you need to disable the internal ads extension. See this thread: