I've recently released my first game, called Dreamline to the Google Play store. This game contains a banner ad. In development, the ad showed up as the simple banner saying "This is where your ad will be". All good.
----------
Next, I released the game to the Google Play store. The banner ad was there, but it was always the default "Unity ads" ad. In order to fix this, I went into the Unity dashboard and set the ad test mode to forced false. The dashbord now states "using production ads for all devices" The dashboard says I got 39 impressions, but there are way more requests. (90). Also, when I boot up the game, no ads show up ever, even though I'm connected to the internet.
----------
This is the code I'm using to serve my banner ad:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.SceneManagement;
public class AdManager : MonoBehaviour
{
public string gameId = "3647601";
public bool testMode = false;
public string placementID = "bannerAd";
public Scene activeScene;
public bool isShowing = false;
private static AdManager instance = null;
public static AdManager Instance
{
get { return instance; }
}
// Start is called before the first frame update
private void Awake()
{
if (instance != null && instance != this)
{
Destroy(this.gameObject);
return;
}
else
{
instance = this;
}
if(activeScene.name == "TestStuff")
{
DontDestroyOnLoad(this.gameObject);
}
}
void Start()
{
Advertisement.Initialize(gameId, testMode);
StartCoroutine(ShowBannerWhenReady());
}
IEnumerator ShowBannerWhenReady()
{
while (!Advertisement.IsReady(placementID))
{
yield return new WaitForSeconds(0.5f);
}
Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
Advertisement.Banner.Show(placementID);
}
}
I'm using a dontdestroyonload because every time the player dies, the scene gets reloaded. The dontdestroyonload prevents the ad from reloading as well, which should keep the impression right.
----------
So the question that this all brings me to is: What do I do in order to make my unity ads banner ad show up properly and consistently?
↧