Unity freezes everytime it's supposed to load the ad

I tried doing it with services and the provided info in docs and training but ads wouldn’t show, then i read on the forum that the service was causing some issues and installed the asset pack, after fixing the multiple defined error i’m still getting a freeze everytime the ad should load.

I want an ad to come when the player died 3 times and the ads used to work back in unity 4.6, it’s only after updating to 5.5 that i can’t get it to work again.

code:

  • using UnityEngine.Advertisements;
    • private const int counterReset = 3;
  • public static int counterForAds = counterReset;
      • void Start()
  • {
  • Advertisement.Initialize(“3XXXXX”, true);
  • StartCoroutine(ShowAdWhenReady());
  • StartCoroutine (Countdown());
  • }
  • public static void resetCounter(){
  • counterForAds = counterReset;
  • //if(PlayerPrefs.GetInt(“Score”) > 100){
  • counterForAds–; //}
  • }
      • public void GameOver() //When player dies
  • {
  • StopAllCoroutines();
  • counterForAds–;
  • if(counterForAds <= 0){
  • //pause = 1;
  • print(“GotThisFar”);
  • StartCoroutine(ShowAdWhenReady());
  • resetCounter();
  • } else {
  • StartCoroutine(Restart ());
  • }
  • }
  • IEnumerator ShowAdWhenReady(){
  • print(“GotThisFar2”);
  • while(Advertisement.IsReady())
  • print(“GotThisFar3”);
  • Advertisement.Show();
  • yield return null;
  • }

It gets to GotThisFar2 and then freezes, no errors.

I’m suddenly getting a lot of attention on 9gag for this old unsucessfull game and i really need to get this to work so i can release a new update on the google play store :slight_smile:
Thanks in advance

Fixed, i forgot an ! in front of advertisement.IsReady()) and had to add the AdManager in scene