Skip to content

Instantly share code, notes, and snippets.

@arkilis
Created August 27, 2020 21:57
Show Gist options
  • Save arkilis/442596eb969a12823c435db60ac778e0 to your computer and use it in GitHub Desktop.
Save arkilis/442596eb969a12823c435db60ac778e0 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class InterstitialAdManager : MonoBehaviour {
#if UNITY_IOS
private string gameId = "3685328";
#elif UNITY_ANDROID
private string gameId = "3685329";
#endif
public string placementId = "video";
public bool testMode = true;
void Start() {
// Initialize the Ads service:
Advertisement.Initialize(gameId, testMode);
// Show an ad:
StartCoroutine(ShowInterstitialAdWhenReady());
}
IEnumerator ShowInterstitialAdWhenReady () {
while (!Advertisement.IsReady (placementId)) {
yield return new WaitForSeconds (0.5f);
}
Advertisement.Show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment