41,99 €
Learn to create, publish and monetize your mobile games with the latest Unity 2017 tool-set easily for Android and iOS
If you are a game developer and want to build mobile games for iOS and Android, then this is the book for you. Previous knowledge of C# and Unity is helpful, but not required.
Unity has established itself as an overpowering force for developing mobile games. If you love mobile games and want to learn how to make them but have no idea where to begin, then this book is just what you need. This book takes a clear, step-by-step approach to building an endless runner game using Unity with plenty of examples on how to create a game that is uniquely your own.
Starting from scratch, you will build, set up, and deploy a simple game to a mobile device. You will learn to add touch gestures and design UI elements that can be used in both landscape and portrait mode at different resolutions. You will explore the best ways to monetize your game projects using Unity Ads and in-app purchases before you share your game information on social networks. Next, using Unity's analytics tools you will be able to make your game better by gaining insights into how players like and use your game. Finally, you'll learn how to publish your game on the iOS and Android App Stores for the world to see and play along.
This book takes a clear, step-by-step approach for Unity game developers to explore everything needed to develop mobile games with Unity.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 240
Veröffentlichungsjahr: 2017
BIRMINGHAM - MUMBAI
Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2017
Production reference: 1281117
ISBN 978-1-78728-871-3
www.packtpub.com
Author
John P. Doran
Copy Editor
Dhanya Baburaj
Reviewer
Francesco Sapio
Project Coordinator
Ritika Manoj
Commissioning Editor
Smeet Thakkar
Proofreader
Safis Editing
Acquisition Editor
Larissa Pinto
Indexer
Rekha Nair
ContentDevelopmentEditor
Arun Nadar
Graphics
Jason Monteiro
Technical Editor
Harshal Kadam
Production Coordinator
Nilesh Mohite
John P. Doran is a passionate and seasoned Technical Game Designer, Software Engineer, and Author who is based in Redmond, Washington. His passion for game development began at an early age. He later graduated from DigiPen Institute of Technology with a Bachelor of Science in Game Design.
For over a decade, John has gained extensive hands-on expertise in game development working in various roles ranging from game designer to lead UI programmer working in teams consisting of just himself to over 70 people in student, mod, and professional game projects including working at LucasArts on Star Wars: 1313. Additionally, John has worked in game development education teaching in Singapore, South Korea, and the United States. To date, he has authored over 10 books pertaining to game development.
In addition to teaching, John is also a part of DigiPen’s Research and Development team. Prior to his present ventures, he was an award-winning videographer.
Francesco Sapio received his Master of Science in Engineering in Artificial Intelligence and Robotics degree from Sapienza University of Rome, Italy, a couple of semesters in advance, graduating summa cum laude; he is currently a PhD researcher at the same university.
He is a Unity 3D and Unreal expert, skilled game designer, and experienced user of major graphics programs. He developed Game@School (Sapienza University of Rome), an educational game for high-school students to learn concepts of physics, and the Sticker Book series (Dataware Games), a cross-platform series of games for kids. In addition, he worked as a consultant for the (successfully funded by Kickstarter) game Prosperity – Italy 1434 (Entertainment Game Apps, Inc.) and for an open online collaborative ideation system, titled Innovoice (Sapienza University of Rome). He has also been involved in different research projects such as Belief-Driven Pathfinding (Sapienza University of Rome), which is a new technique for path-finding in video games that was presented as a paper at the DiGRAFDG Conference 2016, and perfekt.ID (Royal Melbourne Institute of Technology), which included developing a recommendation system for games.
Francesco is an active writer on the topic of game development. Recently, Recently, he authored the book Getting Started with Unity 5.x 2D Game Development (Packt Publishing) that takes your hand and guide you through the amazing journey of game development, the successful Unity UI Cookbook (Packt Publishing), which has been translated also in other languages, that teaches readers how to develop exciting and practical user interfaces for games within Unity, and a short e-guide What do you need to know about Unity (Packt Publishing). In addition, he co-authored the book Unity 5.x 2D Game Development Blueprints (Packt Publishing), and the video course Unity 5.x Game Development Projects (Packt Publishing). Furthermore, he has also been a reviewer for the following books: Game Audio Development with Unity 5.x (Packt Publishing), Game Development Patterns and Best Practices (Packt Publishing), Game Physics Cookbook (Packt Publishing), Mastering Unity 5.x (Packt Publishing), Unity 5.x by Example (Packt Publishing), and Unity Game Development Scripting (Packt Publishing); as well as for the following video courses: Building an FPS Game with Unity and UFPS (Packt Publishing), Enhancement with Unity UI Advanced (Packt Publishing), and Making Sense of Data with Java (Packt Publishing).
Francesco is also a musician and a composer, especially of soundtracks for short films and video games. For several years, he worked as an actor and dancer, where he was a guest of honor at the Teatro Brancaccio in Rome. In addition, he has volunteered as a children's entertainer at the Associazione Culturale Torraccia in Rome. Finally, Francesco loves math, philosophy, logic, and puzzle solving, but most of all, creating video games—thanks to his passion for game designing and programming.
For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
Building Your Game
Chapter overview
Your objectives
Setting up the project
Creating the player
Improving our scripts with attributes and XML comments
Using attributes
The Tooltip attribute
The Range attribute
The RequireComponent attribute
XML comments
Putting it all together
Having the camera following our player
Creating a basic tile
Making it endless
Creating obstacles
Summary
Setup for Android and iOS Development
Chapter overview
Our objectives
Introduction to build settings
Building a project for PC
Installing the Java Development Kit (JDK)
Installing the Android SDK
Exporting a project for Android
Putting the project on your Android device
Unity for iOS setup and Xcode installation
Building a project for iOS
Summary
Mobile Input/Touch Controls
Chapter overview
Our objectives
Using mouse input
Moving via touch
Implementing a gesture
Using the accelerometer
Detecting touch on game objects
Summary
Resolution Independent UI
The chapter overview
Our objectives
Creating a title screen
The Rect Transform component
Anchors
Pivots
Selecting different aspect ratios
Working with buttons
Adding a pause menu
Pausing the game
Summary
Advertising Using Unity Ads
Chapter overview
Your objectives
Unity Ads setup
Displaying a simple Ad
Utilizing ad callback options
Opt-in advertisements with rewards
Adding in a cooldown
Summary
Implementing In-App Purchases
Chapter overview
Your objectives
Setting up Unity IAP
Creating our first purchase
Adding button to restore purchases
Configuring purchases for the stores of your choice
Summary
Getting Social
Chapter overview
Your objectives
Adding a score system
Sharing high scores via Twitter
Downloading and installing Facebook's SDK
Logging in to our game via Facebook
Displaying Facebook name and profile pic
Summary
Using Unity Analytics
Chapter overview
Your objectives
Setting up analytics
Tracking custom events
Using the AnalyticsTracker component
Customizing events through code
Working with the funnel analyzer
Tweaking properties with remote settings
Summary
Making Your Title Juicy
Chapter overview
Your objectives
Animation using iTween
iTween setup
Creating a Simple Tween
Adding Tweens to the pause menu
Working with materials
Using post-processing effects
Adding particle effects
Summary
Game Build and Submission
Chapter overview
Your objectives
Building a release copy of our game
Putting your game on the Google Play Store
Setting up the Google Play Console
Publishing an app on Google Play
Putting your game on the Apple iOS App Store
Apple Developer setup and the creation of a provisioning profile
Adding an app onto iTunes Connect
Summary
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 2017 Mobile Game Development will take readers 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 see some ways to monetize our game by discussing Unity's in-app purchase and advertisement systems. 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.
Chapter 1, Building Your Game,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, Setup for Android and iOS Development, will show the setup required to deploy a project to both iOS and Android mobile devices, by installing the Java and Android SDKs for Android and configuring Xcode for iOS.
Chapter 3, Mobile Input/Touch Controls, shows a number of ways in which input can work on mobile devices. Starting off with mouse events, we will dive into recognizing touch events and gestures, as well as how to use the accelerometer and accessing information using the Touch class.
Chapter 4, Resolution Independent UI, discusses how to build the user interface for our game, starting with a title screen, and then build the other menus that we will want to use for our future chapters.
Chapter 5, Advertising Using Unity Ads, shows how to integrate Unity's Ad framework into our project and learn how to create both simple and complex versions of advertisements.
Chapter 6, Implementing In-App Purchases, talks about how to integrate Unity's In-App Purchase (IAP) system into our project and take a look at how to create an IAP that is used for consumable content as well as permanent unlocks.
Chapter 7, Getting Social, shows how to integrate social media into your projects, starting off with sharing high scores using Twitter and then taking a look at how we can use the Facebook SDK in order to display our player's name and profile picture while inside our game.
Chapter 8, Using Unity Analytics, covers some of the different ways that we can integrate Unity's Analytics tools into our projects, tracking custom events as well as using remote settings to allow us to tweak gameplay without having people redownload the game from the store.
Chapter 9, Making Your Title Juicy, introduces the concept of making games juicy with different ways that you can integrate features of juiciness into our projects, including tweening animations, materials, post-processing effects, and adding particle effects.
Chapter 10, Game Build and Submission, goes over the process of submitting our game to the Google Play or iOS App Store, with tips and tricks to help the process go smoother.
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 2017.2.0f3, but the project should work with minimal changes in future versions of the engine.
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. Though Unity allows you to code in C#, Boo, or UnityScript, for this book we will be using C#.
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 required.
Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. You can download the code files by following these steps:
Log in or register to our website using your e-mail address and password.
Hover the mouse pointer on the
SUPPORT
tab at the top.
Click on
Code Downloads & Errata
.
Enter the name of the book in the
Search
box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on
Code Download
.
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-2017-Mobile-Game-Development. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.
As we start off on our journey building mobile games using the Unity game engine, it's important that readers are familiar with the engine itself before we dive into the specifics of building things for mobile platforms. Although there is a chance that you've already built a game and want to transition it to mobile, there will also be readers who haven't touched Unity before, or may have not used it in a long time. This chapter will act as an introduction to newcomers, a refresher for those coming back, and will provide some best practices for those who are already familiar with Unity.
In this chapter, we will build a 3-D endless runner game in the same vein as Imangi Studios, LLC's Temple Run series. In our case, we will have a player who will run continuously in a certain direction, and will dodge obstacles that come in their way. We can also add additional features to the game easily, as the game will endlessly have new things added to it.
Over the course of this chapter, we will create 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. While you may skip this chapter if you're already familiar with Unity, I find it's also a good idea to go through the project so that you know the thought processes behind why the project is made in the way that it is, so you can keep it in mind for your own future titles.
This chapter will be split into a number of topics. It will contain a simple, step-by-step process from beginning to end. Here is the outline of our tasks:
Project setup
Creating the player
Improving scripts using attributes
Having the camera follow the player
Creating a basic tile
Making the game endless
Creating obstacles
Now that we have our goals in mind, let's start building our project:
To get started, open Unity on your computer. For the purpose of this book, we will use Unity 2017.2.0f3, but the steps should work with minimal changes in future versions.
From startup, we'll opt to create a new project by clicking on the
New
button.
Next, under
Project name*
put in a name (I have chosen
MobileDev
) and make sure that
3D
is selected. If
Enable Unity Analytics
is enabled (the check to the left of it says
On
), click on the
Enable Unity Analytics
button again in order to disable it for the time being; we will add it ourselves later on when we go through
Chapter 5
,
Advertising with Unity Ads
. Afterwards, click on
Create project
and wait for Unity to load up:
After it's finished, you'll see the Unity Editor pop up for the first time:
If your layout doesn't look the same as in the preceding screenshot, you may go to the top-right section of the toolbar and select the drop-down menu there that reads
Layers
. From there, select
Default
from the options presented.