Hello,
I have an android game with rewarded ad videos. After updating to the new unity none of my ad code is working anymore... Why would they change this??? It was working so well... I played around with the code and found that the new ad thing is called "AdvertisementSettings" but I have no idea how to use it and I have found nothing online about it... Would anyone be so kind as to show me how to turn my old code into the new syntax?
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Advertisements;
using UnityEngine.UI;
using UnityEngine;
public class PlayAd : MonoBehaviour {
public GameObject Alert;
public void ShowAd()
{
if (Advertisements.IsReady())
{
Advertisement.Show("", new ShowOptions() { resultCallback = HandleAdResult});
FindObjectOfType().showingAd();
}
else
{
//show popup
Alert.SetActive(true);
Alert.GetComponentInChildren().text = "No Reward:\nCheck your internet connection";
}
}
private void HandleAdResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
FindObjectOfType().doubleClams();
break;
case ShowResult.Skipped:
AdSkipped();
FindObjectOfType().changeScreen();
break;
case ShowResult.Failed:
AdFailed();
FindObjectOfType().changeScreen();
break;
}
}
void AdSkipped()
{
//show popup
Alert.SetActive(true);
Alert.GetComponentInChildren().text = "No Reward:\nAd was skipped.";
}
void AdFailed()
{
//show popup
Alert.SetActive(true);
Alert.GetComponentInChildren().text = "No Reward:\nCheck your internet connection";
}
}
↧