Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question What happens if we call Advertisement.Load multiple times?

Discussion in 'Unity Ads & User Acquisition' started by ddadkhah, Dec 28, 2021.

Thread Status:
Not open for further replies.
  1. ddadkhah

    ddadkhah

    Joined:
    Nov 6, 2017
    Posts:
    59
    Hello,
    When we call Advertisement.Load(unitId), the ad video is downloaded. Right?
    I want to know what happens if I call it multiple times? Would it be downloaded again?
    I want to know, because I want to consider user network traffic to be minimum.
     
    D12294 likes this.
  2. Unity_Quinn

    Unity_Quinn

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    102
    Hi @ddadkhah,

    I've just tested using Charles Proxy. It looks like subsequent load calls will cause additional network traffic.

    In general, we don't recommend attempting to load another ad while you already have one loaded.

    Have a great day!
     
    ddadkhah and D12294 like this.
  3. D12294

    D12294

    Joined:
    Oct 6, 2020
    Posts:
    81
    Hello @Unity_Quinn,
    I'm also on implementing ads the first time for an app and would like to know if there is any use case to load another ad while we already have one loaded? Are multiple loaded ads buffered and then shown one after each other on consecutive Show calls until they are shown all? Or is there only one ad loaded and then the previous loaded ad is discared on new Load call. Would appreciate a link to any documentation to such toppics if you know if there exists one.
    Greetings David
     
  4. Unity_Quinn

    Unity_Quinn

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    102
    Hi David,

    Attempting to load an ad unit that already has an ad loaded is unexpected behavior. My rule of thumb as a support agent is to advise against this as it tends to cause issues, and those issues tend to be difficult to diagnose without seeing someone's integration code.

    When I integrate our ads SDK into a test or hobby project, I will typically place my Load calls in the initialization callback (OnInitializationComplete), and when an ad is finished showing (OnUnityAdsShowComplete). I expect this implementation would be sufficient for most publishers' use cases.

    Our new documentation hub for ads is here: https://docs.unity.com/ads/UnityAdsHome.htm
    I'd recommend starting with the integration guides and copy/pasting some of the code examples, and making some tweaks from there.
     
  5. D12294

    D12294

    Joined:
    Oct 6, 2020
    Posts:
    81
    Thanks for your reply @Unity_Quinn,

    I think this part is missing in the docs and could be very useful for others too if it will be added there.

    Greetings David
     
    Unity_Quinn likes this.
  6. mpugliesivr

    mpugliesivr

    Joined:
    Jan 7, 2019
    Posts:
    16
    hello @Unity_Quinn
    I am trying to update my games Ads SDK to 4.0.0 but I am having a similar issue. Here is how I am doing:

    Code (CSharp):
    1.         protected AbstractUnityAdsController()
    2.         {
    3.             Advertisement.Initialize(GetGameId(), TestMode, this);
    4.         }
    5.  
    6.         public string GetGameId()
    7.         {
    8.             return Application.platform == RuntimePlatform.IPhonePlayer ? IosId : AndroidId;
    9.         }
    10.  
    11.         public void OnInitializationComplete()
    12.         {
    13.             Advertisement.Load(GetIdForPlacementType(AdPlacementType.REWARDED), this);
    14.         }
    I am using Unity 2019.4.16f1 and it simply freezes unity. If I remove the Advertisement.Load part, it works properly.
    Also, if I invoke Advertisement.Load after 500ms (and in the main thread), it give me these errors:


    As you can see, it starts the ads correctly, but after calling Advertisement.Load, for some reason it calls OnInitializationFailed.

    Could you help me on this, please?
     
  7. mpugliesivr

    mpugliesivr

    Joined:
    Jan 7, 2019
    Posts:
    16
    Ok, I am sorry to bother, it was my bad in the end.
    I was using a wrong placement id, and on OnUnityAdsFailedToLoad I was just trying to load again, which caused the freeze (infinite loop). After fixing the placement Id, it worked.
     
    Unity_Quinn likes this.
Thread Status:
Not open for further replies.