我允许用户通过点击按钮观看统一视频广告而获得奖励。当广告准备就绪时,如果您点击该按钮,则会显示一个视频,但不会跳过该选项。我也为货币添加点数。
finally
广告运行正常,至少在测试模式下,您无法跳过它们。您还可以获得10分的观看奖励。问题是,如果我发布广告,关闭我的应用,然后重新打开它,广告就会消失,我有10个加分。
有没有办法查找用户是否观看完整视频以防止有人作弊?
答案 0 :(得分:0)
使用此代码:
using UnityEngine;
using UnityEngine.Advertisements;
public class UnityAdsExample : MonoBehaviour
{
public void ShowRewardedAd()
{
if (Advertisement.IsReady("rewardedVideo"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show("rewardedVideo", options);
}
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("The ad was successfully shown.");
//
// YOUR CODE TO REWARD THE GAMER
// Give coins etc.
break;
case ShowResult.Skipped:
Debug.Log("The ad was skipped before reaching the end.");
break;
case ShowResult.Failed:
Debug.LogError("The ad failed to be shown.");
break;
}
}
}
有关更多信息,请检查documentations。