using UnityEngine;
using System.Collections;
using ADInterstitialAd = UnityEngine.iOS.ADInterstitialAd;
public class NewBehaviourScript : MonoBehaviour {
private ADInterstitialAd fullscreenAd = null;
void Start()
{
fullscreenAd = new ADInterstitialAd();
ADInterstitialAd.onInterstitialWasLoaded += OnFullscreenLoaded;
ADInterstitialAd.onInterstitialWasViewed += OnFullscreenViewed;
}
void WantToShowAD()
{
if(fullscreenAd.loaded)
fullscreenAd.Show();
else
fullscreenAd.ReloadAd();
}
void OnFullscreenLoaded()
{
// you can show ad right here, or, for example, you can start preparing your UI
Debug.Log("AD Loaded\n");
}
void OnFullscreenViewed()
{
// If we reach this stage, it means the user viewed the Ad past the initial screen.
// This could be a good point to reward the user (eg. give an in-game bonus item).
// You can also start reloading the Ad here if you are not using built-in auto reloading.
Debug.Log("AD Viewed\n");
fullscreenAd.ReloadAd();
}
void OnGUI()
{
if(GUI.Button(new Rect(20,20,200,200), "AD"))
WantToShowAD();
}
}