Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Unity广告不会加载_C#_Unity3d - Fatal编程技术网

C# Unity广告不会加载

C# Unity广告不会加载,c#,unity3d,C#,Unity3d,我做了一个新的项目来测试Unity广告,我的项目只有一个脚本,非常简单,可以在点击时显示广告,但它不显示 到目前为止我做了什么 创建统一广告帐户 已创建AdMob帐户 把他们联系起来 进口统一货币化3.2.0 在测试上运行广告这仅仅意味着即使我的admob没有激活,至少我应该得到测试广告 密码 剧本 控制台 你知道可能出了什么问题吗?看来你错过了初始化步骤。我建议通过官方考试。您的脚本应该更像这样: using System.Collections; using System.Collectio

我做了一个新的项目来测试Unity广告,我的项目只有一个脚本,非常简单,可以在点击时显示广告,但它不显示

到目前为止我做了什么 创建统一广告帐户 已创建AdMob帐户 把他们联系起来 进口统一货币化3.2.0 在测试上运行广告这仅仅意味着即使我的admob没有激活,至少我应该得到测试广告 密码 剧本

控制台


你知道可能出了什么问题吗?

看来你错过了初始化步骤。我建议通过官方考试。您的脚本应该更像这样:

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)
        }
    }
}

谢谢dave,快速提问,测试模式签入服务是否与bool testMode相同?为什么我还需要在我的脚本中添加它?我不确定我没有使用UnityAds,但这是他们在文档中创建它的方式。为了安全起见,我会在测试时使用这两种方法。
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)
        }
    }
}