Admob 横幅在 Unity 中不可见但仍可点击

我正在开发一个根据场景显示横幅的应用程序。我使用 Show 和 Hide 来控制这种行为。

第一次显示横幅时效果很好,但第二次(隐藏后)横幅没有出现。但是,横幅区域仍然可以点击,并且按预期执行。

我正在使用 AdMob 统一插件的最新版本(v3.15.1),但我无法找到任何解决该问题的方法。

为了显示广告,我只是调用了 ShowAd 方法,而为了隐藏它们,我调用了 QuitAd 方法。我认为两者都按预期执行,因为它们在第一次被调用时工作,并且因为在调用 HideAd 的场景中“横幅区域”不可点击,但是当调用 ShowAd 方法时,您可以点击不可见的横幅。

感谢您的任何帮助!


慕尼黑8549860
浏览 113回答 2
2回答

慕沐林林

在我的情况下,画布由于某种原因重叠了横幅,我只是在PlayerSettings -> Resolution and Presentation中取消选中“ Render Over native UI ” ,现在它工作正常。

SMILET

我通过销毁 QuitAd 方法中的横幅解决了这个问题:public void QuitAd(TypeOfAd typeOfAd){    switch (typeOfAd)    {        case TypeOfAd.Banner:            Debug.Log("Quiting Banner ad");            bannerAd.Destroy();            break;        case TypeOfAd.Interestitial:            Debug.Log("Quiting Interestitial ad");            Debug.LogError("QuitAd Interestitial Not Implemented");            break;        case TypeOfAd.RewardedVideo:            Debug.Log("Quiting RewardedVideo ad");            Debug.LogError("QuitAd RewardedVideo Not Implemented");            break;    }}然后我修改了 ShowAd 方法,在显示横幅之前加载它:public bool ShowAd(TypeOfAd typeOfAd){    if (DataManager.instance.showAds)        switch (typeOfAd)        {            case TypeOfAd.Banner:                Debug.Log("Showing Banner ad");                LoadAd(TypeOfAd.Banner); //Every time the banner is asked to be shown it will try to load before being shown.                this.bannerAd.Show(); //Will be show after loading                return true;            case TypeOfAd.Interestitial:                Debug.Log("Showing Interestitial ad");                if (this.interstitialAd.IsLoaded())                {                    this.interstitialAd.Show();                    return true;                }                else                {                    Debug.LogWarning("Trying to show InterstitialAd but it is not loaded");                    //TBD: Automaitcally load?                }                break;            case TypeOfAd.RewardedVideo:                Debug.Log("Showing RewardedVideo ad");                if (this.rewardedVideoAd.IsLoaded())                {                    this.rewardedVideoAd.Show();                    return true;                } else {                    Debug.LogWarning("Trying to show RewardedBasedVideoAd but it is not loaded");                    //TBD: Automaitcally load?                }                break;        }    return false;}但是,我不知道这是否是一个正确的解决方案,因为每次必须显示横幅时都会执行新的加载请求(在未显示横幅的场景之后)。此外,这个“解决方案”只是针对同一目标的不同方法,而不是原始方法的修复。因此,如果有人知道为什么原始代码不起作用,我将非常感谢分享这些知识。
打开App,查看更多内容
随时随地看视频慕课网APP