简体   繁体   English

Unity Admob非页内广告未显示

[英]Unity Admob Interstitial Ads Not Showing

I know this question has been asked several times but i got stuck even though i have implemented and tried all the solutions. 我知道这个问题已经被问过几次了,但是即使我已经实施并尝试了所有解决方案,我仍然陷于困境。 I follow this tutorial for interstitial ads showing: 我会按照本教程中的插页式广告来显示:

https://developers.google.com/admob/unity/interstitial https://developers.google.com/admob/unity/interstitial

My main goal is to show ad whenever user taps on "Restart" button for the game. 我的主要目标是在用户点击游戏的“重新启动”按钮时展示广告。

Here is my main ad manager class (which is linked with an game object): 这是我的主要广告管理器类(与游戏对象链接):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;

public class AdManager : MonoBehaviour {

    public string interstitial_id;
    public string app_id;
    public InterstitialAd interstitial;

    // Use this for initialization
    void Start () {
        //MobileAds.Initialize(app_id);
        DontDestroyOnLoad(this);
        Prepare_Video();
        Debug.Log("Admob ilklendirildi: " + interstitial.ToString());
    }


    public void Show_Video()
    {
        Debug.Log("Reklam hazırlık durumu: " + interstitial.IsLoaded());
        if (interstitial.IsLoaded()) {
            Debug.Log("Reklam hazır, gösterilecek");
            interstitial.Show();
        }
        else
        {
            Prepare_Video();
            interstitial.Show();
        }
    }

    public void Destroy_Video()
    {
        if(interstitial != null)
        {
            interstitial.Destroy();
        }
    }

    public void Prepare_Video()
    {
        interstitial = new InterstitialAd(interstitial_id);
        AdRequest request = new AdRequest.Builder().Build();
        interstitial.LoadAd(request);
    }

}

I call the show method in restart action: 我在重启操作中调用show方法:

  public void RestartScene()
    {
        GameStatusText.gameObject.SetActive(false);
        RestartButton.gameObject.SetActive(false);
        MeterText.gameObject.SetActive(false);
        MeterTextTop.text = "";
        Time.timeScale = 1;
        TimeController.TimeLeft = 50f;
        FindObjectOfType<AdManager>().Show_Video();
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }

您需要先初始化admob

检查分配给AdManager的场景的情况,是否有任何更改,是否在游戏中安装了Google Ads unity资源?

I have reinstalled the admob plugin and followed the instructions from the beginning. 我已经重新安装了admob插件,并从一开始就按照说明进行操作。 It worked. 有效。 It seems like my plugin package was damaged and some files were missing. 似乎我的插件包已损坏,缺少一些文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM