Last active
August 29, 2015 14:26
-
-
Save jcguarinpenaranda/600c45760112f47a82cb to your computer and use it in GitHub Desktop.
Show Ads when Unity game starts
This file contains 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 UnityEngine; | |
using System.Collections; | |
using UnityEngine.Advertisements; | |
public class SimpleAds : MonoBehaviour | |
{ | |
//Change to your gameID code in | |
//unityads.unity3d.com | |
string gameID = "33675"; | |
void Start () | |
{ | |
Advertisement.Initialize (gameID, true); | |
StartCoroutine (ShowAdWhenReady()); | |
} | |
IEnumerator ShowAdWhenReady() | |
{ | |
while (!Advertisement.isReady()) | |
yield return null; | |
Advertisement.Show (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment