Utilizing ad callback methods
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 project 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 the game once the ad is finished. To do so, perform the following steps:
- Let’s first open up the
UnityAdController
class and add the following variable and update theStart
function to the following:/// <summary> /// A static reference to this object /// </summary> public static UnityAdController...