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.
-
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)
-
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)
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Advertisements;
public class VideoAds : MonoBehaviour
{
#if UNITY_ANDROID || UNITY_IOS || UNITY_EDITOR
private const string SkippablePlacementID = "video";
private const string RewardedPlacementID = "rewardedVideo";
public string PlacementID => AdType == VideoAdType.Skippable ? SkippablePlacementID : RewardedPlacementID;
public bool IsReady { get; private set; }
public event Action<VideoAdType> OnAdReady;
public event Action<ShowResult> OnAdFinished;
public VideoAdType AdType;
private void Start() => MakeReady();
public void Show()
{
if (Advertisement.IsReady(PlacementID))
{
var options = new ShowOptions { resultCallback = OnAdFinished };
Advertisement.Show(PlacementID, options);
}
else
OnAdFinished(ShowResult.Failed);
IsReady = false;
}
public void MakeReady()
{
StartCoroutine(Ready());
}
IEnumerator Ready()
{
while (!Advertisement.IsReady(PlacementID))
{
yield return new WaitForSeconds(1f);
}
IsReady = true;
OnAdReady?.Invoke(AdType);
}
#endif
}