Preface
As an indie or AAA game developer, you want to have your games where your customers are. More and more people buy mobile devices every year and there's no sign of this stopping any time soon. One of the big advantages of the Unity game engine is that it is cross-platform, making it easy to write your game once and then port it to other consoles with minimal changes. However, there are certain features unique to working with mobile devices, which is what this book is about.
Unity 2020 Mobile Game Development will take you on an exploration of how to use Unity when trying to deploy your content to mobile devices. Over the course of the book, we will see how to create a mobile game and then see how to deploy it to both iOS and Android. We will explore how to add input for mobile devices and have the interface adapt to the many different screen sizes that phones have. We'll then look at some ways to monetize our game by discussing Unity's in-app purchase and advertisement systems. We will also learn how to use notifications to keep users coming back to our game. Then, we will see how we can share our game with the world by enabling us to use Twitter and Facebook's SDK. Afterward, we will see how to work with Unity's analytics system and then polish our title in a number of different ways, before putting it on the Google Play and iOS app stores. Finally, we will also learn how to use Unity's new AR Foundation framework, which allows you to build future-proof AR apps.
Who this book is for
If you are a Unity game developer and want to build mobile games for iOS and Android, then this is the book for you. Previous knowledge of C# is helpful, but not mandatory.
What this book covers
Chapter 1, covers the creation of a simple project in Unity, which we will be modifying over the course of this book to make use of features commonly seen in mobile games. This chapter will also serve as a refresher for some fundamental concepts when working in Unity.
Chapter 2, Project
Chapter 3,
Chapter 4,
Chapter 5,
Chapter 6,
Chapter 7,
Chapter 8, Keeping Players Involved with Notifications, shows how to integrate notifications into your projects starting with the setup, before creating basic notifications ahead of time, and then seeing how to customize how the notifications are presented.
Chapter 9,
Chapter 10,
Chapter 11, , goes over the process of submitting our game to the Google Play or iOS app stores, with tips and tricks to help the process go smoother.
Chapter 12, Augmented Reality, shows the process of adding augmented reality to your games. We start off by setting up the project and going through the installation and setup process for ARCore, ARKit, and AR Foundation. We will then see how to detect surfaces in the real world before seeing how the user can interact with their environment and how to spawn objects within an AR space.
To get the most out of this book
Throughout this book, we will work within the Unity 3D game engine, which you can download from http://unity3d.com/unity/download/. The projects were created using Unity 2020.1.0f1, but the project should work with minimal changes in future versions of the engine. If you would like to download the exact version used in this book, and there is a new version out, you can visit Unity's download archive at https://unity3d.com/get-unity/download/archive. You can also find the system requirements for Unity at https://docs.unity3d.com/2020.1/Documentation/Manual/system-requirements.html in the Unity Editor system requirements section. To deploy your project, you will need an Android or iOS device.
For the sake of simplicity, we will assume that you are working on a Windows-powered computer when developing for Android and a Macintosh computer when developing for iOS. For this book, we will be using C# as our scripting language.
If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Download the example code files
You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
- Log in or register at www.packt.com.
- Select the Support tab.
- Click on Code Downloads.
- Enter the name of the book in the Search box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
- WinRAR/7-Zip for Windows
- Zipeg/iZip/UnRarX for Mac
- 7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Unity-2020-Mobile-Game-Development-Second-Edition. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781838987336_ColorImages.pdf.
Conventions used
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Rename the sphere to Player and set the Transform component's position to (0, 1, -4)."
A block of code is set as follows:
/// <summary>
/// Update is called once per frame
/// </summary>
void Update ()
{
// Check if target is a valid object
if (target != null)
{
// Set our position to an offset of our target
transform.position = target.position + offset;
// Change the rotation to face target
transform.LookAt(target);
}
}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
[Tooltip("How fast the ball moves forwards automatically")]
[Range(0, 10)]
public float rollSpeed = 5;
Bold: Indicates a new term, an important word, or words that you see on screen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Reviews
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packt.com.