Unity Admob 插页式广告不显示
Unity Admob Interstitial Ads Not Showing
我知道这个问题已经被问过好几次了,但即使我已经实施并尝试了所有的解决方案,我还是卡住了。我按照本教程进行插页式广告展示:
https://developers.google.com/admob/unity/interstitial
我的主要目标是在用户点击游戏的 "Restart" 按钮时展示广告。
这是我的主要广告管理器 class(与游戏对象链接):
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);
}
}
我在重启动作中调用了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);
}
检查分配给 AdManager
的场景发生了什么,如果场景有任何变化,您的游戏中是否安装了 Google 广告统一资产?
你需要先初始化admob
我已经重新安装了 admob 插件,并从头开始按照说明进行操作。有效。好像我的插件包损坏了,部分文件丢失了
我知道这个问题已经被问过好几次了,但即使我已经实施并尝试了所有的解决方案,我还是卡住了。我按照本教程进行插页式广告展示:
https://developers.google.com/admob/unity/interstitial
我的主要目标是在用户点击游戏的 "Restart" 按钮时展示广告。
这是我的主要广告管理器 class(与游戏对象链接):
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);
}
}
我在重启动作中调用了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);
}
检查分配给 AdManager
的场景发生了什么,如果场景有任何变化,您的游戏中是否安装了 Google 广告统一资产?
你需要先初始化admob
我已经重新安装了 admob 插件,并从头开始按照说明进行操作。有效。好像我的插件包损坏了,部分文件丢失了