为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

C#
慕尼黑8549860 2022-10-23 14:00:54
我正在开发一个根据场景显示横幅的应用程序。我使用 Show 和 Hide 来控制这种行为。第一次显示横幅时效果很好,但第二次(隐藏后)横幅没有出现。但是,横幅区域仍然可以点击,并且按预期执行。我正在使用 AdMob 统一插件的最新版本(v3.15.1),但我无法找到任何解决该问题的方法。为了显示广告,我只是调用了 ShowAd 方法,而为了隐藏它们,我调用了 QuitAd 方法。我认为两者都按预期执行,因为它们在第一次被调用时工作,并且因为在调用 HideAd 的场景中“横幅区域”不可点击,但是当调用 ShowAd 方法时,您可以点击不可见的横幅。感谢您的任何帮助!
查看完整描述

2 回答

?
慕沐林林

TA贡献2016条经验 获得超9个赞

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



查看完整回答
反对 回复 2022-10-23
?
SMILET

TA贡献1796条经验 获得超4个赞

我通过销毁 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;

}

但是,我不知道这是否是一个正确的解决方案,因为每次必须显示横幅时都会执行新的加载请求(在未显示横幅的场景之后)。


此外,这个“解决方案”只是针对同一目标的不同方法,而不是原始方法的修复。


因此,如果有人知道为什么原始代码不起作用,我将非常感谢分享这些知识。


查看完整回答
反对 回复 2022-10-23
  • 2 回答
  • 0 关注
  • 112 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号