问题
When I am using unity, the console shows Dummy LoadAD, Dummy Show, etc. But when I test it on my phone it does show any AD. I set these two functions on two-button. bannerAD button does not show bannerAD. videoAD button will close my app
There's my code
using UnityEngine;
using GoogleMobileAds.Api;
using System;
using UnityEngine.UI;
public class admanageger : MonoBehaviour
{
public Text adstatus;
BannerView bannerView;
RewardedAd rewardedAd;
string appID = "ca-app-pub-#####~#####";
// Start is called before the first frame update
private void Awake()
{
}
void Start()
{
MobileAds.Initialize(appID);
}
public void showbannerAD()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-####/####";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-###/#####";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
this.bannerView.LoadAd(request);
}
public void showvideoAD()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-#####/####";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-#####/#####";
#else
string adUnitId = "unexpected_platform";
#endif
this.rewardedAd = new RewardedAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the rewarded ad with the request.
this.rewardedAd.LoadAd(request);
this.rewardedAd.Show();
}
}
Am I do something wrong or and setting need about Admob?
回答1:
AdMob won't show any ads on Unity Editor. You should always test your Ad related stuff by building and testing on your phone.
来源:https://stackoverflow.com/questions/63578879/admob-ad-dont-showunity