I have tried to adjust, format the code in every shape and form, this is the code that I most recently used and still does not work!
private InterstitialAd interstitial;
void Update ()
{
if (Input.GetKeyDown(KeyCode.Escape)) {
ShowInterstitial();
}
}
private void RequestInterstitial()
{
interstitial = new InterstitialAd("ca-app-pub-4978585600967291/*******");
// Create an empty ad request.
AdRequest request = new AdRequest.Builder ().Build ();
// Load the interstitial with the request.
interstitial.LoadAd (request);
}
private void ShowInterstitial()
{
interstitial.Show();
}
else
{
print("Interstitial is not ready yet.");
}
}
}
What I am trying to do is, when the user presses the back button the on Android, it will show the ad, then if they press it again, the application quits.
↧