googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.38k stars 1.08k forks source link

'GoogleMobileAdsSettings' does not contain a definition for 'Instance' #3196

Closed enissimsir closed 8 months ago

enissimsir commented 8 months ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

I am working on an old Unity Project. I just imported the GoogleMobileAds but I got an exception:

Assets\GoogleMobileAds\Editor\AndroidBuildPostProcessor.cs(14,38): error CS0117: 'GoogleMobileAdsSettings' does not contain a definition for 'Instance'

I guess it is because of GoogleMobileAdsSettings.Instance method is deleted in the new versions of the plugin. What can I do to fix that?

Relevant Code:

if (!GoogleMobileAdsSettings.Instance.IsAdManagerEnabled && !GoogleMobileAdsSettings.Instance.IsAdMobEnabled)
{
    NotifyBuildFailure("Neither Ad Manager nor AdMob is enabled yet.");
}
NVentimiglia commented 8 months ago

@enissimsir You are accessing an old API.

The new API uses LoadInstance().

https://github.com/googleads/googleads-mobile-unity/blob/main/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsSettings.cs#L16