Unity 2020 Mobile Game Development
eBook - ePub

Unity 2020 Mobile Game Development

Discover practical techniques and examples to create and deliver engaging games for Android and iOS, 2nd Edition

John P. Doran

  1. 464 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Unity 2020 Mobile Game Development

Discover practical techniques and examples to create and deliver engaging games for Android and iOS, 2nd Edition

John P. Doran

Book details
Book preview
Table of contents
Citations

About This Book

A practical guide on how to use Unity for building cross-platform mobile games and Augmented Reality apps using the latest Unity 2020 toolset

Key Features

  • Create, deploy, and monetize captivating and immersive games on Android and iOS platforms
  • Take your games into the real world by adding augmented reality features to your mobile projects
  • Kick-start your mobile game development journey with step-by-step instructions and a demo game project

Book Description

Unity 2020 brings a lot of new features that can be harnessed for building powerful games for popular mobile platforms. This updated second edition delves into Unity development, covering the new features of Unity, modern development practices, and augmented reality (AR) for creating an immersive mobile experience. The book takes a step-by-step approach to building an endless runner game using Unity to help you learn the concepts of mobile game development.

This new edition also covers AR features and explains how to implement them using ARCore and ARKit with Unity. The book explores the new mobile notification package and helps you add notifications for your games. You'll learn how to add touch gestures and design UI elements that can be used in both landscape and portrait modes at different resolutions. The book then covers the best ways to monetize your games using Unity Ads and in-app purchases before you learn how to integrate your game with various social networks. Next, using Unity's analytics tools, you'll enhance your game by gaining insights into how players like and use your game. Finally, you'll take your games into the real world by implementing AR capabilities and publishing them on both Android and iOS app stores.

By the end of this book, you will have learned Unity tools and techniques and be able to use them to build robust cross-platform mobile games.

What you will learn

  • Design responsive user interfaces for your mobile games
  • Detect collisions, receive user input, and create player movements for your mobile games
  • Create interesting gameplay elements using inputs from your mobile device
  • Explore the mobile notification package in Unity game engine to keep players engaged
  • Create interactive and visually appealing content for Android and iOS devices
  • Monetize your game projects using Unity Ads and in-app purchases

Who this book is for

If you are a game developer or mobile developer who wants to learn Unity and use it to build mobile games for iOS and Android, then this Unity book is for you. Prior knowledge of C# and Unity will be beneficial but is not mandatory.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Unity 2020 Mobile Game Development an online PDF/ePUB?
Yes, you can access Unity 2020 Mobile Game Development by John P. Doran in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming Games. We have over one million books available in our catalogue for you to explore.

Information

Year
2020
ISBN
9781838980993
Edition
2
Resolution-Independent UI
When working on mobile devices, one of the things that you'll need to spend a fair bit of time on is the User Interface (UI). Unlike when developing projects for PC, where you only need to care about a single resolution or aspect ratio, there are many different devices out there with different resolutions and aspect ratios when building for mobile. For instance, we have phones, which fit in our pocket, but also tablets, which are huge. Not only that, but mobile games can also be played horizontally or vertically.
A Graphical User Interface (GUI) is the way that players interact with your games. You've actually been using a GUI in all of the previous chapters (the Unity Editor) and also when interacting with your operating system. Without a GUI of some sort, the only way you'd be able to interact with a computer is a command prompt, such as DOS or UNIX.
When working on GUIs, we want them to be as intuitive as possible and to only contain information that is pertinent to the player at any given time. There are people whose main job is programming and/or designing UIs, and there are college degrees on the subject as well. So, while we won't talk about everything to do with using GUIs, I do want to touch on the aspects that should be quite helpful when working on your own projects in the future.
When building for mobile, it's very important that you design your UI to be resolution-independent—that is, to ensure that the UI will scale and adjust itself to fit any screen size that is given to it. This will not only help us now but also in the future.
In this chapter, we will build the UI for our game, starting with a title screen, and then build the other menus that we will want to use for future chapters. This chapter will be split into a number of topics. The chapter is a simple step-by-step process from beginning to end. The following is the outline of our tasks:
  • Creating a title screen
  • Adding UI elements to the screen
  • Implementing a pause menu
  • Pausing the game
  • Adapting GUIs for notch devices

Technical requirements

This book utilizes Unity 2020.1.0f1 and Unity Hub 2.3.1, but the steps should work with minimal changes in future versions of the editor. 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. You can find the code files present in this chapter on GitHub at https://github.com/PacktPublishing/Unity-2020-Mobile-Game-Development-Second-Edition/tree/master/Chapter%2004.

Creating a title screen

Now, before we start adding UI elements to our game, let's first set up some groundwork and foundational knowledge by creating something that we will need anyway—a title screen:
  1. To start, we'll go ahead and create a new scene for us to work with by going to File | New Scene. When dealing with a UI, we will often want to see a visual representation of what will be drawn on the screen, so we will want to make use of 2D mode to have a better representation of what our UI will look like in the final version of the game.
  2. To do that, go to the Scene view tab—you'll see the control bar menu with a 2D button on it underneath that. Click on it, and you should see the camera automatically move into something that looks similar to the following screenshot:
The 2D button switches the camera between 2D and 3D views. In 2D mode, you'll note that the Scene Gizmos is gone due to the fact that the only option is to look perpendicularly at the XY plane (the x axis pointing to the right and the y axis pointing upward) and that our camera has changed to an orthographic view.
  1. We have to create a Text object with the name of our game. Go to the menu and select GameObject | UI | Text.
Note that while this book is using the included-by-default Unity UI system and Text objects, the following steps also work with TextMesh Pro objects and all of the concepts in this chapter work the same with both systems. If you are interested in using TextMesh Pro with your project, you can find more information on the additional steps required to import and utilize it in your project: https://learn.unity.com/tutorial/quickstart-to-textmesh-pro-2019-3.
  1. This will create three new objects, as you can see in the Hierarchy view:
    • Canvas: This is the area where all of the UI elements will reside, and if you try to create a UI element without one already existing, Unity will create one for you like it just did here. From the Scene view tab, it will draw a white rectangle around itself to show you how large it is and will resize itself depending on how large the Game view is:
  2. ...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Dedication
  4. About Packt
  5. Contributors
  6. Preface
  7. Building Your Game
  8. Project Setup for Android and iOS Development
  9. Mobile Input/Touch Controls
  10. Resolution-Independent UI
  11. Advertising Using Unity Ads
  12. Implementing In-App Purchases
  13. Getting Social
  14. Keeping Players Involved with Notifications
  15. Using Unity Analytics
  16. Making Your Title Juicy
  17. Game Build and Submission
  18. Augmented Reality
  19. Other Books You May Enjoy