- Home /
test ads unity
i have my app effectively ready to be released its all fine but one problem, im not sure if the ads work so to confirm if they do i need help. How can i edit my code to make it so test ads work on the unity editor just to confirm. I want this for banner and regular ads.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdMobManager : MonoBehaviour
{
private BannerView bannerView;
bool showAd;
[SerializeField]
private string appID =
[SerializeField] private string bannerID =
[SerializeField] private string regularAD =
void Start()
{
StartCoroutine("Timer");
}
IEnumerator Timer()
{
while (true)
{
yield return new WaitForSeconds(240.0f);
showAd = true;
while (showAd)
{
yield return new WaitForEndOfFrame();
}
}
}
public void OnClickShowBanner()
{
if (showAd)
{
this.RequestBanner();
}
}
public void OnClickShowAd()
{
if (showAd)
{
this.RequestRegularAD();
}
}
private void RequestRegularAD()
{
InterstitialAd AD = new InterstitialAd(regularAD);
AdRequest request = new AdRequest.Builder().Build();
AD.LoadAd(request);
showAd = false;
}
private void RequestBanner()
{
bannerView = new BannerView(bannerID, AdSize.Banner, AdPosition.Bottom);
AdRequest request = new AdRequest.Builder().Build();
bannerView.LoadAd(request);
showAd = false;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612202431im_/https://answers.unity.com/themes/thub/images/avi.jpg)