Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug Ads not initializing, but placeholder still showing

Discussion in 'Unity Ads & User Acquisition' started by RickFromTheParty, Nov 14, 2023.

  1. RickFromTheParty

    RickFromTheParty

    Joined:
    Feb 23, 2021
    Posts:
    3
    In my game, when a player dies they have the option to click a Continue button, which calls this function from my
    GameOverHandler 
    class:
    Code (CSharp):
    1. public void Continue()
    2. {
    3.     AdManager.Instance.ShowAd(this);
    4.     continueButton.interactable = false;
    5. }
    ShowAd is a custom function that does the following
    Code (CSharp):
    1. public void ShowAd(GameOverHandler gameOverHandler)
    2. {
    3.     this.gameOverHandler = gameOverHandler;
    4.     Advertisement.Load(adUnitId, this);
    5. }
    Ultimately, the placeholder ad shows up, but when I click the Close button it does not call the
    OnUnityAdsShowComplete
    function, which runs the code to continue playing.

    I've filled up my code with Debug.Logs and found a few confusing things:
    1. Despite the placeholder ad showing up,
      OnInitializationComplete
      never runs.
    2. After
      Advertisement.Initialize
      is run,
      Advertisement.isInitialized
      is never set to
      true
      .
    TL;DR: As far as I know, the placeholder should not show up if the advertisement is never initialized, but it seems to be getting there somehow. Additionally, even though the ad placeholder appears, clicking the Close button does not trigger
    OnUnityAdsShowComplete
    function.

    What am I missing? Thank you for any help!

    GameOverHandler.cs - Pastebin
    AdManager.cs - Pastebin

     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
  3. RickFromTheParty

    RickFromTheParty

    Joined:
    Feb 23, 2021
    Posts:
    3
    It is implemented and the required functions are all in the class. But no worries, we found a solution! A colleague of mine was able to get it working by upgrading to a newer version of Unity.

    I was too lazy to go that far, however, so I ended up changing the version of the Advertisement package from v3.75 to v4.4.2. It changed the name of the package to Advertisement Legacy and even though it's probably not officially supported by the version of Unity I'm using, it did the job and made all of the functions work as intended without having to upgrade the project to a newer version of Unity.

    Hooray for laziness!
     
  4. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Glad to hear the issue has been resolved. The ad package is renamed to distinguish newer ad packages and this does not mean that the editor version does not support it, more information about this can be seen here: https://forum.unity.com/threads/current-status-of-advertisement-legacy-package.1423509/