Skip to content

Instantly share code, notes, and snippets.

@arkilis
Created August 24, 2020 20:23
Show Gist options
  • Save arkilis/97d5c1f8a6b4db62a54655be7bb4c074 to your computer and use it in GitHub Desktop.
Save arkilis/97d5c1f8a6b4db62a54655be7bb4c074 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class BannerAdManager : MonoBehaviour {
#if UNITY_IOS
private string gameId = "1234567";
#elif UNITY_ANDROID
private string gameId = "1234568";
#endif
public string placementId = "my_banner";
public bool testMode = true;
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment