0
爲什麼當我進入下一個名爲「Main」的場景時,我的admob橫幅不會隱藏? 我做的一切都是別人在其他線程說什麼..Unity - Admob隱藏橫幅不起作用
這是我的代碼:
using GoogleMobileAds.Api;
public class AdmobAds : MonoBehaviour {
private BannerView bannerView;
private void RequestBanner()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxx";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
BannerView bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
}
public void HideAd()
{
bannerView.Destroy();
bannerView.Hide();
}
void Start()
{
Scene currentScene = SceneManager.GetActiveScene();
string sceneName = currentScene.name;
if (sceneName == "Menu")
{
RequestBanner();
}
else if (sceneName == "Main")
{
bannerView.Destroy();
bannerView.Hide();
}
}
}
另外,'公共無效HideAd'被attachted啓動按鈕,它仍然不隱藏橫幅..
我該怎麼辦?
謝謝:)它的工作原理 – Jip1912