Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Multiple VideoAd Requests

Discussion in 'Unity Ads' started by shkar-noori, Jan 12, 2019.

  1. shkar-noori


    Jun 10, 2013
    Hello All!

    I'm developing a game for iOS and Android and i have integrated Unity Ads
    There are a few unclear things about Unity Ads that i hoped i can get the answers from the forum.
    1. I'm using Unity 2018.3.0f2, should i use the built in ads? or the Monetization SDK? what's the difference? (also i cant find the banner ads in the built in version)
    2. is it okay to request multiple ad placements at a time before actually needing to show the ad? i have an example use case for this, when the game starts, i request two ad placements, video and rewardedVideo, if the player scores above half the best score and dies, they're shown a rewardedVideo (it's ready because its been requested before hand), and a video otherwise (ready because its ready before hand)

      Code (CSharp):
      1. using System;
      2. using System.Collections;
      3. using UnityEngine;
      4. using UnityEngine.Advertisements;
      6. public class VideoAds : MonoBehaviour
      7. {
      9.     private const string SkippablePlacementID = "video";
      10.     private const string RewardedPlacementID = "rewardedVideo";
      11.     public string PlacementID => AdType == VideoAdType.Skippable ? SkippablePlacementID : RewardedPlacementID;
      12.     public bool IsReady { get; private set; }
      14.     public event Action<VideoAdType> OnAdReady;
      15.     public event Action<ShowResult> OnAdFinished;
      17.     public VideoAdType AdType;
      19.     private void Start() => MakeReady();
      21.     public void Show()
      22.     {
      23.         if (Advertisement.IsReady(PlacementID))
      24.         {
      25.             var options = new ShowOptions { resultCallback = OnAdFinished };
      26.             Advertisement.Show(PlacementID, options);
      27.         }
      28.         else
      29.             OnAdFinished(ShowResult.Failed);
      31.         IsReady = false;
      32.     }
      33.     public void MakeReady()
      34.     {
      35.         StartCoroutine(Ready());
      36.     }
      38.     IEnumerator Ready()
      39.     {
      40.         while (!Advertisement.IsReady(PlacementID))
      41.         {
      42.             yield return new WaitForSeconds(1f);
      43.         }
      44.         IsReady = true;
      45.         OnAdReady?.Invoke(AdType);
      46.     }
      47. #endif
      48. }
  2. ap-unity


    Unity Technologies

    Aug 3, 2016

    The latest version of the Ads SDK is 3.0.0 and it is currently only available on the Asset Store. You will have to disable the built-in version of Unity Ads (from the Package Manager and the Service Window). SDK 3.0 is currently the only way to access the Banner API (in Advertisement.Banner).

    We don't currently have an API to request a video. Requests happen automatically during initialization and once an ad starts playing, the next one is requested. So that's not a step you have to worry about.

    The Ads SDK will request the ad assets to fill as many placements as possible. We do not need to distinguish between a rewarded and non-rewarded placement at the request. The overlay is typically the only thing that changes between a rewarded video and a non-rewarded video.
    shkar-noori likes this.
  3. shkar-noori


    Jun 10, 2013
    thanks for the reply!