Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unity 2017 Mobile Game Development

You're reading from   Unity 2017 Mobile Game Development Build, deploy, and monetize games for Android and iOS with Unity

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781787288713
Length 360 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
John P. Doran John P. Doran
Author Profile Icon John P. Doran
John P. Doran
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Building Your Game FREE CHAPTER 2. Setup for Android and iOS Development 3. Mobile Input/Touch Controls 4. Resolution Independent UI 5. Advertising Using Unity Ads 6. Implementing In-App Purchases 7. Getting Social 8. Using Unity Analytics 9. Making Your Title Juicy 10. Game Build and Submission

Utilizing ad callback options

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:

  1. 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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime