我已经创建了一个新项目来测试Unity Ads,我的项目只有1个脚本(非常简单),可以在点击时显示广告,但是没有显示。
script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class AdMo : MonoBehaviour
{
public void showADD()
{
if(Advertisement.IsReady()){
Advertisement.Show();
Debug.Log("this");
} else {
Debug.Log("that"); //this will return instead (see image below)
}
}
}
console
您知道什么地方可能出问题了吗?
答案 0 :(得分:1)
似乎您缺少初始化步骤。我建议通过官方Integration guide for Unity。您的脚本应该看起来像这样:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class AdMo : MonoBehaviour
{
string gameId = "1234567";
bool testMode = true;
// Initialize the Ads service:
void Start () {
Advertisement.Initialize (gameId, testMode);
}
public void showADD()
{
if(Advertisement.IsReady()){
Advertisement.Show();
Debug.Log("this");
} else {
Debug.Log("that"); //this will return instead (see image below)
}
}
}