我有这个代码,每次打印出该视频后,我都会用按钮控制台执行它,但它失败了。也许我只是不知道如何在Unity中启用广告。我启用了测试模式。这是我的代码。 :
FIXED 我只需要替换此行
public string placementId =“rewardedVideo”;
用这个:
Advertisement.Show(placementId,options);
私人字符串gameId =“1523603”;
void Start(){
Advertisement.Initialize (gameId);
}
public void ShowAd (){
var options = new ShowOptions();
options.resultCallback = HandleShowResult;
Debug.Log (Advertisement.IsReady ("rewardedVideo"));
Advertisement.Show(gameId, options);
}
void HandleShowResult (ShowResult result){
if(result == ShowResult.Finished) {
Debug.Log("Video completed - Offer a reward to the player");
OnemoreTry ();
}else if(result == ShowResult.Skipped) {
Debug.LogWarning("Video was skipped - Do NOT reward the player");
}else if(result == ShowResult.Failed) {
Debug.LogError("Video failed to show");
}
}