Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Multiple VideoAd Requests

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

Thread Status:
Not open for further replies.
  1. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    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;
      5.  
      6. public class VideoAds : MonoBehaviour
      7. {
      8. #if UNITY_ANDROID || UNITY_IOS || UNITY_EDITOR
      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; }
      13.  
      14.     public event Action<VideoAdType> OnAdReady;
      15.     public event Action<ShowResult> OnAdFinished;
      16.  
      17.     public VideoAdType AdType;
      18.  
      19.     private void Start() => MakeReady();
      20.  
      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);
      30.  
      31.         IsReady = false;
      32.     }
      33.     public void MakeReady()
      34.     {
      35.         StartCoroutine(Ready());
      36.     }
      37.  
      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. }
      49.  
     
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @shkar-noori

    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).
    https://assetstore.unity.com/packages/add-ons/services/unity-monetization-3-0-66123

    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

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    thanks for the reply!
     
Thread Status:
Not open for further replies.