The code we wrote for the LoadLevel function works perfectly fine when we go to the main menu of the game; however, if we dive into the game itself from the main menu, the game will still be going on in the background with the ad blocking the player from playing the game.
When running your app on an actual mobile device, the Unity Player will pause while Unity Ads are shown. However, if you are testing in the Unity Editor, the game is not paused while the placeholder ads are shown. However, we can simulate that behavior ourselves using the Advertisement.ShowOptions class.
We will pause the game when an ad is shown and then resume once the ad is finished. To do so, perform the following steps:
- Let's first open up the UnityAdController class and update it to the following:
using UnityEngine;
#if UNITY_ADS // Can only compile ad code on support...