一切正常。下载和展示广告。显示一个给了1条生命。我想要的是取消广告后不要给予奖励。离开广告时也会感到恼火。如何确保广告在关闭后不会被杀死?我该怎么做 ?是否有功能可以检查广告是否被完全跟踪?还是有一个功能可以检查广告是否关闭?然后我可以确定广告的持续时间谢谢您的关注
`
// Get singleton reward based video ad reference.
this.rewardBasedVideo = RewardBasedVideoAd.Instance;
// RewardBasedVideoAd is a singleton, so handlers should only be registered once.
this.rewardBasedVideo.OnAdLoaded += this.HandleRewardBasedVideoLoaded;
this.rewardBasedVideo.OnAdFailedToLoad += this.HandleRewardBasedVideoFailedToLoad;
this.rewardBasedVideo.OnAdOpening += this.HandleRewardBasedVideoOpened;
this.rewardBasedVideo.OnAdStarted += this.HandleRewardBasedVideoStarted;
this.rewardBasedVideo.OnAdRewarded += this.HandleRewardBasedVideoRewarded;
this.rewardBasedVideo.OnAdClosed += this.HandleRewardBasedVideoClosed;
this.rewardBasedVideo.OnAdLeavingApplication += this.HandleRewardBasedVideoLeftApplication;
}
public void Update()
{
// Calculate simple moving average for time to render screen. 0.1 factor used as smoothing
// value.
this.deltaTime += (Time.deltaTime - this.deltaTime) * 0.1f;
}
// Returns an ad request with custom ad targeting.
private AdRequest CreateAdRequest()
{
return new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator)
.AddTestDevice("0123456789ABCDEF0123456789ABCDEF")
.AddKeyword("game")
.SetGender(Gender.Male)
.SetBirthday(new DateTime(1985, 1, 1))
.TagForChildDirectedTreatment(false)
.AddExtra("color_bg", "9B30FF")
.Build();
}
private void RequestRewardBasedVideo()
private void ShowRewardBasedVideo()
{
if (this.rewardBasedVideo.IsLoaded())
{
this.rewardBasedVideo.Show();
}
else
{
MonoBehaviour.print("Reward based video ad is not ready yet");
}
}`
注意:切掉一些小部分,因为它不发布代码。如果您告诉我不要仅在取消广告中提供奖励的意思就足够了。
答案 0 :(得分:3)
您在代码中订阅了OnAdRewarded
事件:
this.rewardBasedVideo.OnAdRewarded += this.HandleRewardBasedVideoRewarded;
用户观看完视频后,将调用您的this.HandleRewardBasedVideoRewarded
方法。
您可以使用OnAdClosed
查看广告是否关闭。
在这里查看所有事件