Промежуточная реклама в сети аудитории не работает! Единство 3D - PullRequest
0 голосов
/ 20 марта 2019

Я сделал игру с Unity 3D и добавил к ней интерстициальную рекламу для аудитории Facebook.

Промежуточная реклама была успешно загружена при запуске сцены, но не показалась, и я получил этосообщение в консоли:

Размещено промежуточное объявление.

Не могли бы вы помочь мне решить эту проблему?

Сценарий GameManager:

    using UnityEngine.SceneManagement;
    using AudienceNetwork;

public class GameManager : MonoBehaviour {

    private InterstitialAd interstitialAd;
    private bool isLoaded;
    bool shown = false;
    static int loadCount = 0;

    bool GameHasEnded = false;
    float NextLevelDelay = 1f;
    float RestartDelay = 2f;


    void Start () {

        this.LoadInterstitial();
    }

    public void ShowInterstitial()
    {
        if (this.isLoaded)
        {
            this.interstitialAd.Show();
            this.isLoaded = false;
            Debug.Log("Interstitial Shown");
        }
        else
        {
            Debug.Log("Interstitial Ad not loaded!");
        }
    }

    public void CompleteLevel()
    {
        Invoke("NextLevel", NextLevelDelay);
    }

    public void EndGame()
    {    
        if (GameHasEnded == false)
        {
            GameHasEnded = true;
            Invoke("Restart", RestartDelay);
        }
    }

    public void NextLevel()
    {
        if ((loadCount % 2) == 0)  // only show ad every third time
        {
            if (!shown)
            {
                ShowInterstitial();
                shown = true;
            }
        }
        SceneManager.LoadScene(SceneManager.GetActiveScene().path);
        loadCount = loadCount + 1;
    }

    void Restart()
    {
        if ((loadCount % 2) == 0)  // only show ad every third time
        {
            if (!shown)
            {
                ShowInterstitial();
                shown = true;
            }
        }
        SceneManager.LoadScene(SceneManager.GetActiveScene().path);
        loadCount = loadCount + 1;
    }

    public void LoadInterstitial()
    {
        this.interstitialAd = new InterstitialAd("DEMO_AD_TYPE#YOUR_PLACEMENT_ID");
        this.interstitialAd.Register(this.gameObject);

        // Set delegates to get notified on changes or when the user interacts with the ad.
        this.interstitialAd.InterstitialAdDidLoad = (delegate () {
            Debug.Log("Interstitial ad loaded.");
            this.isLoaded = true;
        });
        interstitialAd.InterstitialAdDidFailWithError = (delegate (string error) {
            Debug.Log("Interstitial ad failed to load with error: " + error);
        });
        interstitialAd.InterstitialAdWillLogImpression = (delegate () {
            Debug.Log("Interstitial ad logged impression.");
        });
        interstitialAd.InterstitialAdDidClick = (delegate () {
            Debug.Log("Interstitial ad clicked.");
        });

        this.interstitialAd.interstitialAdDidClose = (delegate () {
            Debug.Log("Interstitial ad did close.");
            if (this.interstitialAd != null)
            {
                this.interstitialAd.Dispose();
            }
        });

        // Initiate the request to load the ad.
        this.interstitialAd.LoadAd();
    }

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...