- Home /
Advertisement code not working anymore.
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<PlayerController>().showingAd();
}
else
{
//show popup
Alert.SetActive(true);
Alert.GetComponentInChildren<Text>().text = "No Reward:\nCheck your internet connection";
}
}
private void HandleAdResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
FindObjectOfType<PlayerController>().doubleClams();
break;
case ShowResult.Skipped:
AdSkipped();
FindObjectOfType<PlayerController>().changeScreen();
break;
case ShowResult.Failed:
AdFailed();
FindObjectOfType<PlayerController>().changeScreen();
break;
}
}
void AdSkipped()
{
//show popup
Alert.SetActive(true);
Alert.GetComponentInChildren<Text>().text = "No Reward:\nAd was skipped.";
}
void AdFailed()
{
//show popup
Alert.SetActive(true);
Alert.GetComponentInChildren<Text>().text = "No Reward:\nCheck your internet connection";
}
}
where you are loading your ad ? where you are checking the callbacks for the ads ? Please make sure your ad is loading.
The script worked perfectly fine, it's not about loading anything. It's about the new update. Before updating all of my ads worked perfectly, now nothing works.
Your answer
Follow this Question
Related Questions
Admob for iPhone? 7 Answers
How to implement Live In game billboard ads 1 Answer
Android Java Proxy could not be found. 0 Answers
Unity ads problem for mobile 0 Answers
Unity ads eCPM doesn't show anything 0 Answers