Created
August 27, 2020 21:57
-
-
Save arkilis/442596eb969a12823c435db60ac778e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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