I install google admob sdk from this url Release Google Mobile Ads Unity Plugin v5.1.0 · googleads/googleads-mobile-unity · GitHub.
But the using GoogleMobileAds.Api; reference is missing.
using System;
using UnityEngine;
using GoogleMobileAds.Api; //THIS REFERENCE MISSING
public class AdmobManager : MonoBehaviour
{
private InterstitialAd interstitial;
private BannerView bannerView;
public void Start()
{
#if UNITY_ANDROID
string appId = "ca-app-pub-5911743213156480~5159541036";
#elif UNITY_IPHONE
string appId = "ca-app-pub-3940256099942544~1458002511";
#else
string appId = "unexpected_platform";
#endif
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(appId);
RequestInterstitialAds();
RequestBanner();
}
private void RequestBanner()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-5911743213156480/9909590242";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);
// Create an empty ad request.
// Load the banner with the request.
bannerView.LoadAd(CreateNewRequest());
}
public void ShowInterstitialAds()
{
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
public void ShowBannerAd()
{
if (bannerView != null)
{
bannerView.Show();
}
}
private void RequestInterstitialAds()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-5911743213156480/3275382212";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#endif
interstitial = new InterstitialAd(adUnitId);
interstitial.LoadAd(CreateNewRequest());
}
private AdRequest CreateNewRequest()
{
return new AdRequest.Builder().Build();
}
}
Someone can help me?