Unity AdMob 如何在场景变化时隐藏横幅广告?

How do you hide banner ads on scene changes Unity AdMob?

我正在创建一个新的 Unity 应用程序,我希望在玩游戏时在屏幕顶部显示横幅广告 运行。但是,我不想在任何其他场景中有横幅广告。我已经尝试了几乎所有可能的方法,但只有一种代码组合可以让我什至 运行 广告。任何其他组合都会导致立即崩溃。我在下面附上了我正在使用的代码,但它只显示广告并且无法隐藏它们。

using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;

public class Banner : MonoBehaviour {
    void Start(){
        BannerView bannerView = new BannerView ("************", AdSize.Banner, AdPosition.Top);
        AdRequest request = new AdRequest.Builder().Build ();
        bannerView.LoadAd(request);
        bannerView.Show();
    }
}

卸载(销毁)场景时销毁 BannerView:

using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;

public class Banner : MonoBehaviour {
    private BannerView bannerView;

    void Start() {
        bannerView = new BannerView ("************", AdSize.Banner, AdPosition.Top);
        AdRequest request = new AdRequest.Builder().Build ();
        bannerView.LoadAd(request);
        bannerView.Show();
    }

    void OnDestroy() {
        bannerView.Destroy();
    }
}