奖励视频没有显示,也没有奖励。团结3d

时间:2017-11-17 21:26:21

标签: c# unity3d admob

我的广告在游戏中显示,当玩家在盒子对撞机上发射激光轮时,该对撞机应该触发奖励视频广告然后给予玩家500个硬币。问题是,即使广告说它在控制台中加载(见下文),广告也不显示并给予奖励。我只使用adMob所以我不需要更改任何调解设置(我相信)。我试图将它上传到我的手机上,但仍然没有得到任何结果。有关解决这个问题的任何想法吗?

附带问题 - 我也想知道这是否仅仅是使用测试广告的问题?

控制台

Dummy .ctor
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:.ctor() (at Assets/GoogleMobileAds/Common/DummyClient.cs:28)
GoogleMobileAds.GoogleMobileAdsClientFactory:BuildRewardBasedVideoAdClient() (at Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs:57)
System.Reflection.MethodBase:Invoke(Object, Object[])
GoogleMobileAds.Api.RewardBasedVideoAd:.ctor() (at Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs:43)
GoogleMobileAds.Api.RewardBasedVideoAd:.cctor() (at Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs:25)
RewardVideoPic:Start() (at Assets/_Scripts/RewardVideoPic.cs:28)
RewardVideoPic:Start() (at Assets/_Scripts/RewardVideoPic.cs:17)

Dummy CreateRewardBasedVideoAd
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:CreateRewardBasedVideoAd() (at Assets/GoogleMobileAds/Common/DummyClient.cs:124)
GoogleMobileAds.Api.RewardBasedVideoAd:.ctor() (at Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs:44)
GoogleMobileAds.Api.RewardBasedVideoAd:.cctor() (at Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs:25)
RewardVideoPic:Start() (at Assets/_Scripts/RewardVideoPic.cs:28)
RewardVideoPic:Start() (at Assets/_Scripts/RewardVideoPic.cs:17)

Dummy LoadAd
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:LoadAd(AdRequest, String) (at Assets/GoogleMobileAds/Common/DummyClient.cs:134)
GoogleMobileAds.Api.RewardBasedVideoAd:LoadAd(AdRequest, String) (at Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs:121)
RewardVideoPic:Start() (at Assets/_Scripts/RewardVideoPic.cs:25)

Dummy IsLoaded
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:IsLoaded() (at Assets/GoogleMobileAds/Common/DummyClient.cs:108)
GoogleMobileAds.Api.RewardBasedVideoAd:IsLoaded() (at Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs:127)
RewardVideoPic:ShowAd() (at Assets/_Scripts/RewardVideoPic.cs:40)
RewardVideoPic:OnTriggerEnter(Collider) (at Assets/_Scripts/RewardVideoPic.cs:34)

Dummy ShowRewardBasedVideoAd
UnityEngine.Debug:Log(Object)
GoogleMobileAds.Common.DummyClient:ShowRewardBasedVideoAd() (at Assets/GoogleMobileAds/Common/DummyClient.cs:144)
GoogleMobileAds.Api.RewardBasedVideoAd:Show() (at Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs:133)
RewardVideoPic:ShowAd() (at Assets/_Scripts/RewardVideoPic.cs:42)
RewardVideoPic:OnTriggerEnter(Collider) (at Assets/_Scripts/RewardVideoPic.cs:34)

代码

using System;
using UnityEngine;
using UnityEngine.UI;
using GoogleMobileAds.Api;

public class RewardVideoPic : MonoBehaviour {

    public Text CoinText;
    //  public laserScript AutoFire;
    private bool reward = false;
    private RewardBasedVideoAd rewardBasedVideo;


    void Start()
    {
        // Get singleton reward based video ad reference.
        this.rewardBasedVideo = RewardBasedVideoAd.Instance;

        string adUnitId = "ca-app-pub-3940256099942544/5224354917";

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();

        // Load the rewarded video ad with the request.
        this.rewardBasedVideo.LoadAd(request, adUnitId);
        rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;

    }

    void OnTriggerEnter(Collider other)
    {
        if(other.tag == "laserBullet")
        {
            ShowAd();
        }
    }

    private void ShowAd()
    {
        if (rewardBasedVideo.IsLoaded())
        {
            rewardBasedVideo.Show();
        }
    }

    public void HandleRewardBasedVideoRewarded(object sender, Reward args)
    {
        reward = true;
    }

    void Update()
    {
        if (reward == true)
        {
            PlayerPrefs.SetInt("Coins", PlayerPrefs.GetInt("Coins") + 500);
            CoinText.text = PlayerPrefs.GetInt("Coins").ToString();
            reward = false;

        }
    }
}

0 个答案:

没有答案