Hi there!
Well, I’m new to the unity ad, and i’m using the integrated version in unity 5.3
In my app, there is a blanc scene with the Advertisement, and other with the application. Whenever the player loses, the app is restarted by my Ad scene.
The problem is: when the player restart the app by the third time, the Ad is not being showed!
My app is not in the player Store yet, here lies the problem?
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.SceneManagement;
public class AdvertisementManagement : MonoBehaviour {
public bool showAds = true;
public float timeOut = 5f;
private bool hasShownAd = false;
void Awake () {
if (Advertisement.isSupported) {
Advertisement.Initialize ("1115287", false);
}
}
void Start () {
OnLevelWasLoaded (0);
}
public void Update () {
ShowAd ();
}
public void ShowAd () {
if (showAds) {
if (!hasShownAd) {
if (!Advertisement.IsReady ()) {
timeOut -= Time.deltaTime;
if (timeOut <= 0) {
//hasShownAd = true;
Application.Quit ();
}
}
else {
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show (null, options);
hasShownAd = true;
}
}
else {
SceneManager.LoadScene ("Application");
}
}
}
void OnLevelWasLoaded (int level) {
if (level == 0)
ShowAd ();
}
private void HandleShowResult (ShowResult result) {
switch (result) {
case ShowResult.Finished:
SceneManager.LoadScene ("Application");
break;
case ShowResult.Skipped:
SceneManager.LoadScene ("Application");
break;
case ShowResult.Failed:
Application.Quit ();
break;
}
}
}
Thanks for any kind of help!