Admob 横幅在 Unity 中不可见但仍可点击
Admob banner is invisible but still clickable in Unity
我正在开发一款根据场景显示横幅的应用。我使用 Show 和 Hide 来控制这种行为。
第一次显示横幅时效果很好,但第二次(隐藏后)横幅没有出现。但是,横幅区域仍然可以点击并且按预期执行。
我正在使用最新版本的 AdMob 统一插件 (v3.15.1),但我找不到任何解决问题的方法。
这是我的代码:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds;
using GoogleMobileAds.Api;
public class AdsManager //Ads information: https://developers.google.com/admob/unity (see left menu fo detailed info of each ad type)
{
public static AdsManager instance;
public BannerView bannerAd;
public InterstitialAd interstitialAd;
public RewardBasedVideoAd rewardedVideoAd;
#if UNITY_EDITOR
private static String appId = "unused";
private static String bannerAdId = "unused";
private static String interistitialAdId = "unused";
private static String rewardedVideAdId = "TBD";
#elif UNITY_ANDROID
private static String appId = "ca-app-pub-6685658831663319~7807395346";
private static String bannerAdId = "ca-app-pub-3940256099942544/6300978111"; //"ca-app-pub-6685658831663319/9607562172";
private static String interistitialAdId = "ca-app-pub-3940256099942544/1033173712"; //"ca-app-pub-6685658831663319/4875778545";
private static String rewardedVideAdId = "ca-app-pub-3940256099942544/5224354917"; //"ca-app-pub-6685658831663319/2971919290";
#elif UNITY_IOS
private static String appId = "ca-app-pub-6685658831663319~7807395346";
private static String bannerAdId = "ca-app-pub-6685658831663319/9607562172";
private static String interistitialAdId = "ca-app-pub-6685658831663319/4875778545";
private static String rewardedVideAdId = "ca-app-pub-6685658831663319/2971919290";
#else
private static String appId = "unexpected_platform";
private static String bannerAdId = "unexpected_platform";
private static String interistitialAdId = "unexpected_platform";
private static String rewardedVideAdId = "unexpected_platform";
#endif
public enum TypeOfAd
{
Banner,
Interestitial,
RewardedVideo
}
public AdsManager()
{
Debug.Log("Initializing a new AdsManager.");
if (instance == null)
{
instance = this;
Setup();
Debug.Log("AdsManager initialization successful.");
}
else
{
Debug.Log("AdsManager already exists. New initialization unsuccessful.");
}
}
private void Setup()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(appId);
this.bannerAd = new BannerView(bannerAdId, AdSize.SmartBanner, AdPosition.Bottom); //Info to chang banner size: https://developers.google.com/admob/unity/banner#banner_sizes
SetupBannerEventHandlers();
this.interstitialAd = new InterstitialAd(interistitialAdId);
SetupInterstitialEventHandlers();
this.rewardedVideoAd = RewardBasedVideoAd.Instance;
SetupRewardedVideoAdsEventHandlers();
//Load firsts ads
instance.LoadAd(TypeOfAd.Interestitial);
instance.LoadAd(TypeOfAd.Banner);
}
private void SetupBannerEventHandlers()
{
this.bannerAd.OnAdLoaded += HandlerOnBannerAdLoaded;
this.bannerAd.OnAdFailedToLoad += HandlrOnBannerAdFailedToLoad;
this.bannerAd.OnAdOpening += HandlerOnBannerAdOpening;
this.bannerAd.OnAdClosed += HandlerOnBannerAdClosed;
this.bannerAd.OnAdLeavingApplication += HandlerOnBannerAdLeavingApplication;
}
private void SetupInterstitialEventHandlers()
{
this.interstitialAd.OnAdLoaded += HandlerOnInterstitialAdLoaded;
this.interstitialAd.OnAdFailedToLoad += HandlerOnInterstitialAdFailedToLoad;
this.interstitialAd.OnAdOpening += HandlerOnInterstitialAdOpening;
this.interstitialAd.OnAdClosed += HandlerOnInterstitialAdClosed;
this.interstitialAd.OnAdLeavingApplication += HandlerOnInterstitialAdLeavingApplication;
}
private void SetupRewardedVideoAdsEventHandlers()
{
this.rewardedVideoAd.OnAdLoaded += HandlerRewardVideoAdLoaded;
this.rewardedVideoAd.OnAdFailedToLoad += HandlerRewardVideoAdFailedToLoad;
this.rewardedVideoAd.OnAdOpening += HandlerRewardVideoAdOpening;
this.rewardedVideoAd.OnAdStarted += HandlerRewardVideoAdStarted;
this.rewardedVideoAd.OnAdRewarded += HandlerRewardVideoAdRewarded;
this.rewardedVideoAd.OnAdClosed += HandlerRewardVideoAdClosed;
this.rewardedVideoAd.OnAdLeavingApplication += HandlerRewardVideoAdLeftApplication;
}
public void LoadAd(TypeOfAd typeOfAd)
{
if (DataManager.instance.showAds)
switch (typeOfAd)
{
case TypeOfAd.Banner:
Debug.Log("Loading Banner ad");
this.bannerAd.LoadAd(new AdRequest.Builder().Build()); //After loading it, it will be automatically displayed
break;
case TypeOfAd.Interestitial:
Debug.Log("Loading Interestitial ad");
if (!this.interstitialAd.IsLoaded())
this.interstitialAd.LoadAd(new AdRequest.Builder().Build());
break;
case TypeOfAd.RewardedVideo:
Debug.Log("Loading RewardedVideo ad");
if (!this.rewardedVideoAd.IsLoaded())
this.rewardedVideoAd.LoadAd(new AdRequest.Builder().Build(), rewardedVideAdId);
break;
}
}
public bool ShowAd(TypeOfAd typeOfAd)
{
if (DataManager.instance.showAds)
switch (typeOfAd)
{
case TypeOfAd.Banner:
Debug.Log("Showing Banner ad");
this.bannerAd.Show(); //No avaliable check to know if the ad has been loaded...
return true; //...so maybe the return is true but the ad is not being displayed because it was not loaded before.
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;
}
public void QuitAd(TypeOfAd typeOfAd)
{
switch (typeOfAd)
{
case TypeOfAd.Banner:
Debug.Log("Quiting Banner ad");
bannerAd.Hide();
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;
}
}
//BANNER EVENT HANDLERS
public void HandlerOnBannerAdLoaded(object sender, EventArgs args) { } // Called when an ad request has successfully loaded.
public void HandlrOnBannerAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { Debug.LogWarning("Banner failed to load: " + args.Message); LoadAd(TypeOfAd.Banner); } // Called when an ad request failed to load.
public void HandlerOnBannerAdOpening(object sender, EventArgs args) { } // Called when an ad is clicked.
public void HandlerOnBannerAdClosed(object sender, EventArgs args) { } // Called when the user returned from the app after an ad click.
public void HandlerOnBannerAdLeavingApplication(object sender, EventArgs args) { } // Called when the ad click caused the user to leave the application.
//INTERSTITIAL EVENT HANDLERS
public void HandlerOnInterstitialAdLoaded(object sender, EventArgs args) { } // Called when an ad request has successfully loaded.
public void HandlerOnInterstitialAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { Debug.LogWarning("Interstitial failed to load: " + args.Message); LoadAd(TypeOfAd.Interestitial); } // Called when an ad request failed to load.
public void HandlerOnInterstitialAdOpening(object sender, EventArgs args) { } // Called when an ad is shown.
public void HandlerOnInterstitialAdClosed(object sender, EventArgs args) { } // Called when the ad is closed.
public void HandlerOnInterstitialAdLeavingApplication(object sender, EventArgs args) { } // Called when the ad click caused the user to leave the application.
//REWARDED VIDEO AD EVENT HANDLERS
public void HandlerRewardVideoAdLoaded(object sender, EventArgs args) { } // Called when an ad request has successfully loaded.
public void HandlerRewardVideoAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { Debug.LogWarning("RewardedVideo failed to load: " + args.Message); LoadAd(TypeOfAd.RewardedVideo); } // Called when an ad request failed to load.
public void HandlerRewardVideoAdOpening(object sender, EventArgs args) { } // Called when an ad is shown.
public void HandlerRewardVideoAdStarted(object sender, EventArgs args) { } // Called when the ad starts to play.
public void HandlerRewardVideoAdRewarded(object sender, Reward args) { Debug.Log("Rewarded video ad completed. Reward info: " + args.Amount + " of " + args.Type); } // Called when the user should be rewarded for watching a video.
public void HandlerRewardVideoAdClosed(object sender, EventArgs args) { } // Called when the ad is closed.
public void HandlerRewardVideoAdLeftApplication(object sender, EventArgs args) { } // Called when the ad click caused the user to leave the application.
}
为了显示广告,我只是调用 ShowAd 方法,为了隐藏它们,我调用了 QuitAd 方法。我认为两者都按预期执行,因为它们在第一次调用时工作,并且因为在调用 HideAd 的场景中 "banner area" 不可点击,但是当调用 te ShowAd 方法时,您可以点击不可见的横幅。
感谢您的帮助!
我通过在 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;
}
但是,我不知道这是否是一个合适的解决方案,因为每次必须显示横幅时(在未显示横幅的场景之后)都会执行新的加载请求。
此外,此 "solution" 只是对同一 objective 的不同方法,而不是对原始方法的修复。
因此,如果有人知道为什么原始代码不起作用,我将不胜感激分享这些知识。
在我的例子中 canvas 由于某种原因重叠的横幅,我只是取消选中 PlayerSettings 中的“Render Over native UI” - > 分辨率和显示 现在可以正常工作了。
我正在开发一款根据场景显示横幅的应用。我使用 Show 和 Hide 来控制这种行为。
第一次显示横幅时效果很好,但第二次(隐藏后)横幅没有出现。但是,横幅区域仍然可以点击并且按预期执行。
我正在使用最新版本的 AdMob 统一插件 (v3.15.1),但我找不到任何解决问题的方法。
这是我的代码:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds;
using GoogleMobileAds.Api;
public class AdsManager //Ads information: https://developers.google.com/admob/unity (see left menu fo detailed info of each ad type)
{
public static AdsManager instance;
public BannerView bannerAd;
public InterstitialAd interstitialAd;
public RewardBasedVideoAd rewardedVideoAd;
#if UNITY_EDITOR
private static String appId = "unused";
private static String bannerAdId = "unused";
private static String interistitialAdId = "unused";
private static String rewardedVideAdId = "TBD";
#elif UNITY_ANDROID
private static String appId = "ca-app-pub-6685658831663319~7807395346";
private static String bannerAdId = "ca-app-pub-3940256099942544/6300978111"; //"ca-app-pub-6685658831663319/9607562172";
private static String interistitialAdId = "ca-app-pub-3940256099942544/1033173712"; //"ca-app-pub-6685658831663319/4875778545";
private static String rewardedVideAdId = "ca-app-pub-3940256099942544/5224354917"; //"ca-app-pub-6685658831663319/2971919290";
#elif UNITY_IOS
private static String appId = "ca-app-pub-6685658831663319~7807395346";
private static String bannerAdId = "ca-app-pub-6685658831663319/9607562172";
private static String interistitialAdId = "ca-app-pub-6685658831663319/4875778545";
private static String rewardedVideAdId = "ca-app-pub-6685658831663319/2971919290";
#else
private static String appId = "unexpected_platform";
private static String bannerAdId = "unexpected_platform";
private static String interistitialAdId = "unexpected_platform";
private static String rewardedVideAdId = "unexpected_platform";
#endif
public enum TypeOfAd
{
Banner,
Interestitial,
RewardedVideo
}
public AdsManager()
{
Debug.Log("Initializing a new AdsManager.");
if (instance == null)
{
instance = this;
Setup();
Debug.Log("AdsManager initialization successful.");
}
else
{
Debug.Log("AdsManager already exists. New initialization unsuccessful.");
}
}
private void Setup()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(appId);
this.bannerAd = new BannerView(bannerAdId, AdSize.SmartBanner, AdPosition.Bottom); //Info to chang banner size: https://developers.google.com/admob/unity/banner#banner_sizes
SetupBannerEventHandlers();
this.interstitialAd = new InterstitialAd(interistitialAdId);
SetupInterstitialEventHandlers();
this.rewardedVideoAd = RewardBasedVideoAd.Instance;
SetupRewardedVideoAdsEventHandlers();
//Load firsts ads
instance.LoadAd(TypeOfAd.Interestitial);
instance.LoadAd(TypeOfAd.Banner);
}
private void SetupBannerEventHandlers()
{
this.bannerAd.OnAdLoaded += HandlerOnBannerAdLoaded;
this.bannerAd.OnAdFailedToLoad += HandlrOnBannerAdFailedToLoad;
this.bannerAd.OnAdOpening += HandlerOnBannerAdOpening;
this.bannerAd.OnAdClosed += HandlerOnBannerAdClosed;
this.bannerAd.OnAdLeavingApplication += HandlerOnBannerAdLeavingApplication;
}
private void SetupInterstitialEventHandlers()
{
this.interstitialAd.OnAdLoaded += HandlerOnInterstitialAdLoaded;
this.interstitialAd.OnAdFailedToLoad += HandlerOnInterstitialAdFailedToLoad;
this.interstitialAd.OnAdOpening += HandlerOnInterstitialAdOpening;
this.interstitialAd.OnAdClosed += HandlerOnInterstitialAdClosed;
this.interstitialAd.OnAdLeavingApplication += HandlerOnInterstitialAdLeavingApplication;
}
private void SetupRewardedVideoAdsEventHandlers()
{
this.rewardedVideoAd.OnAdLoaded += HandlerRewardVideoAdLoaded;
this.rewardedVideoAd.OnAdFailedToLoad += HandlerRewardVideoAdFailedToLoad;
this.rewardedVideoAd.OnAdOpening += HandlerRewardVideoAdOpening;
this.rewardedVideoAd.OnAdStarted += HandlerRewardVideoAdStarted;
this.rewardedVideoAd.OnAdRewarded += HandlerRewardVideoAdRewarded;
this.rewardedVideoAd.OnAdClosed += HandlerRewardVideoAdClosed;
this.rewardedVideoAd.OnAdLeavingApplication += HandlerRewardVideoAdLeftApplication;
}
public void LoadAd(TypeOfAd typeOfAd)
{
if (DataManager.instance.showAds)
switch (typeOfAd)
{
case TypeOfAd.Banner:
Debug.Log("Loading Banner ad");
this.bannerAd.LoadAd(new AdRequest.Builder().Build()); //After loading it, it will be automatically displayed
break;
case TypeOfAd.Interestitial:
Debug.Log("Loading Interestitial ad");
if (!this.interstitialAd.IsLoaded())
this.interstitialAd.LoadAd(new AdRequest.Builder().Build());
break;
case TypeOfAd.RewardedVideo:
Debug.Log("Loading RewardedVideo ad");
if (!this.rewardedVideoAd.IsLoaded())
this.rewardedVideoAd.LoadAd(new AdRequest.Builder().Build(), rewardedVideAdId);
break;
}
}
public bool ShowAd(TypeOfAd typeOfAd)
{
if (DataManager.instance.showAds)
switch (typeOfAd)
{
case TypeOfAd.Banner:
Debug.Log("Showing Banner ad");
this.bannerAd.Show(); //No avaliable check to know if the ad has been loaded...
return true; //...so maybe the return is true but the ad is not being displayed because it was not loaded before.
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;
}
public void QuitAd(TypeOfAd typeOfAd)
{
switch (typeOfAd)
{
case TypeOfAd.Banner:
Debug.Log("Quiting Banner ad");
bannerAd.Hide();
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;
}
}
//BANNER EVENT HANDLERS
public void HandlerOnBannerAdLoaded(object sender, EventArgs args) { } // Called when an ad request has successfully loaded.
public void HandlrOnBannerAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { Debug.LogWarning("Banner failed to load: " + args.Message); LoadAd(TypeOfAd.Banner); } // Called when an ad request failed to load.
public void HandlerOnBannerAdOpening(object sender, EventArgs args) { } // Called when an ad is clicked.
public void HandlerOnBannerAdClosed(object sender, EventArgs args) { } // Called when the user returned from the app after an ad click.
public void HandlerOnBannerAdLeavingApplication(object sender, EventArgs args) { } // Called when the ad click caused the user to leave the application.
//INTERSTITIAL EVENT HANDLERS
public void HandlerOnInterstitialAdLoaded(object sender, EventArgs args) { } // Called when an ad request has successfully loaded.
public void HandlerOnInterstitialAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { Debug.LogWarning("Interstitial failed to load: " + args.Message); LoadAd(TypeOfAd.Interestitial); } // Called when an ad request failed to load.
public void HandlerOnInterstitialAdOpening(object sender, EventArgs args) { } // Called when an ad is shown.
public void HandlerOnInterstitialAdClosed(object sender, EventArgs args) { } // Called when the ad is closed.
public void HandlerOnInterstitialAdLeavingApplication(object sender, EventArgs args) { } // Called when the ad click caused the user to leave the application.
//REWARDED VIDEO AD EVENT HANDLERS
public void HandlerRewardVideoAdLoaded(object sender, EventArgs args) { } // Called when an ad request has successfully loaded.
public void HandlerRewardVideoAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { Debug.LogWarning("RewardedVideo failed to load: " + args.Message); LoadAd(TypeOfAd.RewardedVideo); } // Called when an ad request failed to load.
public void HandlerRewardVideoAdOpening(object sender, EventArgs args) { } // Called when an ad is shown.
public void HandlerRewardVideoAdStarted(object sender, EventArgs args) { } // Called when the ad starts to play.
public void HandlerRewardVideoAdRewarded(object sender, Reward args) { Debug.Log("Rewarded video ad completed. Reward info: " + args.Amount + " of " + args.Type); } // Called when the user should be rewarded for watching a video.
public void HandlerRewardVideoAdClosed(object sender, EventArgs args) { } // Called when the ad is closed.
public void HandlerRewardVideoAdLeftApplication(object sender, EventArgs args) { } // Called when the ad click caused the user to leave the application.
}
为了显示广告,我只是调用 ShowAd 方法,为了隐藏它们,我调用了 QuitAd 方法。我认为两者都按预期执行,因为它们在第一次调用时工作,并且因为在调用 HideAd 的场景中 "banner area" 不可点击,但是当调用 te ShowAd 方法时,您可以点击不可见的横幅。
感谢您的帮助!
我通过在 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;
}
但是,我不知道这是否是一个合适的解决方案,因为每次必须显示横幅时(在未显示横幅的场景之后)都会执行新的加载请求。
此外,此 "solution" 只是对同一 objective 的不同方法,而不是对原始方法的修复。
因此,如果有人知道为什么原始代码不起作用,我将不胜感激分享这些知识。
在我的例子中 canvas 由于某种原因重叠的横幅,我只是取消选中 PlayerSettings 中的“Render Over native UI” - > 分辨率和显示 现在可以正常工作了。