Search Unity

Load ads async

Discussion in 'Unity Ads & User Acquisition' started by nhutlv01, Apr 29, 2015.

  1. nhutlv01

    nhutlv01

    Joined:
    Nov 17, 2014
    Posts:
    3
    I want to load ads async when the player playing my game, so user don't need to wait for ads loading. Can i do that with unity sdk? Thank for advance!
     
  2. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    After initialization, Unity Ads will begin to cache the first ad. Unity Ads will cache the next available ad after each consecutive ad shown. This way, the ad is cached and ready to be shown when you intend to show the ad.

    For this reason, it's best to initialize Unity Ads when your game first loads. It takes a few seconds for the initialization to complete, and takes time for the first video to be cached. You should allow sufficient time for this process to take place before attempting to show an ad.

    The best solution may be to create a bootstrap scene that initializes Unity Ads any any other components that should be loaded only once throughout the game. You can add the UnityAdsHelper script to any GameObject within the bootstrap scene. The UnityAdsHelper will initialize Unity Ads for you. The static ShowAd() method can be called from any script in your project. This method allows you to pass in methods for handling each of the three potential result states (Finished, Skipped, Failed). It also allows you to pass in a method for handling functionality that should occur outside of these states (or for all three states), like continuing on to the next level.

    You can find example usage of the UnityAdsHelper script within the GetCoinsButton script. Try out the full SpaceAds project to see this example in action.
     
    nhutlv01 likes this.
  3. nhutlv01

    nhutlv01

    Joined:
    Nov 17, 2014
    Posts:
    3
    Your answer was helped me so much. Thank you for your detail answer, Nikkolai.