AdMob导致Fps下降?

问题描述

我已经看到许多有关AdMob和Fps掉线的问题,但是我没有找到解决方案!目前,我正在创建一个简单的无尽的跑步者,当玩家死亡并显示插页式广告时。一切正常,问题在于重启后使用:

Scene manager.LoadScene(Scenemanager.GetActiveScene().buildindex)

Fps几乎开始下降到无法播放的水平。我不知道是什么原因造成的,但是我确定这是由于AdMob(我试图在没有admob的情况下构建游戏,并且一切正常。)每当玩家击中一个对象时,就会调用AdMob脚本。

这是我的admob代码

public class AdMob : MonoBehavIoUr
{
    string App_ID = "*************************************";

    string Interstitial_ID = "ca-app-pub-3940256099942544/1033173712";

    private InterstitialAd interstitial;
    // Start is called before the first frame update
    void Start()
    {
        MobileAds.Initialize(App_ID);
        RequestInterstitial();
    }

    public void RequestInterstitial()
    {
        if (this.interstitial != null)
        {
            this.interstitial.Destroy();
        }
        this.interstitial = new InterstitialAd(Interstitial_ID);

        // Called when an ad request has successfully loaded.
        this.interstitial.OnAdLoaded += HandleOnAdLoaded;
        // Called when an ad request Failed to load.
        this.interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;
        // Called when an ad is shown.
        this.interstitial.OnAdopening += HandleOnAdOpened;
        // Called when the ad is closed.
        this.interstitial.OnAdClosed += HandleOnAdClosed;
        // Called when the ad click caused the user to leave the application.
        this.interstitial.OnAdLeavingApplication += HandleOnAdLeavingApplication;

        AdRequest request = new AdRequest.Builder().Build();
        this.interstitial.LoadAd(request);
    }

    public void ShowInterstitialAd()
    {
        if (this.interstitial.IsLoaded())
        {
            this.interstitial.Show();
        }
    }

    private void Ondisable()
    {
        this.interstitial.Destroy();
    }
    
    public void HandleOnAdLoaded(object sender,EventArgs args)
    {
        MonoBehavIoUr.print("HandleAdLoaded event received");
    }

    public void HandleOnAdFailedToLoad(object sender,AdFailedToLoadEventArgs args)
    {
        MonoBehavIoUr.print("HandleFailedToReceiveAd event received with message: "
                        + args.Message);
    }

    public void HandleOnAdOpened(object sender,EventArgs args)
    {
        MonoBehavIoUr.print("HandleAdOpened event received");
    }

    public void HandleOnAdClosed(object sender,EventArgs args)
    {
        if (this.interstitial != null)
        {
            this.interstitial.Destroy();
        }
    }

    public void HandleOnAdLeavingApplication(object sender,EventArgs args)
    {
        MonoBehavIoUr.print("HandleAdLeavingApplication event received");
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)