Reader small image

You're reading from  Unity Cookbook - Fifth Edition

Product typeBook
Published inNov 2023
Reading LevelIntermediate
PublisherPackt
ISBN-139781805123026
Edition5th Edition
Languages
Tools
Right arrow
Authors (3):
Shaun Ferns
Shaun Ferns
author image
Shaun Ferns

Shaun is a lecturer at Technological University Dublin. He is currently teaching on the BA (Hons) in Creative Digital Media where he is lead in the delivery of the Multimedia Stream. He is currently exploring serious games for construction-related training as well as the opportunities transmedia provides in improving user experience and engagement in cultural archive artifacts. His educational research is currently driven by his interest in self-determined learning (heutagogy), rhizomatic learning theory, micro-credentialing /digital badging, and curriculum development.
Read more about Shaun Ferns

Sinéad Murphy
Sinéad Murphy
author image
Sinéad Murphy

Sinead Murphy is currently Data Analytics Manager for the Irish NGO Trocaire. She has over 25 years of computing experience, including freelance IT training and database consulting, university lecturing in mathematics, IT skills and programming at TU Dublin (Ireland) and Middlesex University (London). She is a published academic, with undergraduate and postgraduate degrees in mathematics, computing and data science. She is passionate about the use of IT for understanding and visualising data, and using that understanding to make meaningful differences in the world. She is currently exploring the use of Python and Unity for data analytics and interactive visualisations.
Read more about Sinéad Murphy

View More author details
Right arrow

Mobile Games and Applications

In this chapter, we will present a set of recipes introducing the techniques you will need to build and deploy Unity games and applications to mobile devices.

Mobile projects might be games for an Apple or Android cell phone, an Augmented Reality (AR) app for an Apple iOS iPad tablet, or perhaps a Virtual Reality (VR) game for a dedicated VR headset. The concepts and skills for deploying to mobile devices are the same for all these uses, so in this chapter, we’ll explore how to set up, build, and deploy games for Android and Apple mobile devices, and you can then use these skills in the following two chapters when you learn how to develop and deploy AR and VR applications.

There are several steps to get from a project in the Unity Editor to a mobile app running on a device. For Android, we need to use the Unity Editor to build an APK Android app executable, and then get that APK file onto the device to install and run. For Apple iOS, there...

Setting up your system for Android mobile app development

There are some basic steps you need to perform to add the modules you need to your editor application so that your Unity Editor application is set up for Android mobile development.

How to do it...

To set up your system for Android mobile app development, do the following:

  1. Open the Unity Hub application and choose the Installs tab on the left.
  2. Now, for the version of the Unity Editor you wish to develop a mobile project for, click the settings “cog” button and click the Add modules button.

Figure 16.2: The Add modules button for an installed Unity Editor version in the Unity Hub application

  1. For Android development, check the Android Build Support modules for your application. Then ensure that both the OpenJDK and Android SDK & NDK Tools sub-modules are also checked, and click the Continue button.

Figure 16.3: Adding the Android Build Support with...

Setting up your system for Apple iOS mobile app development

There are some basic steps you need to perform so that your Unity Editor and Mac computer system are set up for Apple mobile development. In this recipe, you’ll learn how to add the modules you need to your editor application for mobile development, as well as how to link an Apple ID to the Mac Xcode program editor, which is used to build Apple iOS applications.

Getting ready

If you don’t have one already, create a free Apple ID. You can do this when you set up an Apple device, or you can visit the Apple ID section of Apple’s website: appleid.apple.com.

How to do it...

To set up up your system for Apple iOS mobile app development, do the following:

  1. Open the Unity Hub application and choose the Installs tab on the left.
  2. Now, for the version of the Unity Editor you wish to develop a mobile project for, click the settings “cog” button and click the Add modules...

Deploying the Third Person Character Controller Starter project for an Android device

In this recipe, you’ll add the Unity Third Person Character Controller Starter project, configure it for mobile, and then build and run the game on an Android device attached to your computer with a USB cable.

Other ways to get Android APK application files onto a device are explored in the There’s more… section of this recipe.

Figure 16.8: Third-Person Playground scene running on an Android mobile device

Getting ready

Before starting this recipe, ensure you have completed the first recipe in this chapter: Setting up your system for Android mobile app development.

How to do it...

To deploy the Third Person Controller Starter project for an Android device, perform the following steps:

  1. Create a new Unity 3D project.
  2. Open a web browser tab to the Unity Asset Store, by choosing Asset menu: Window | Asset Store.
  3. Search for the...

Deploying the Third Person Character Controller Starter project for an Apple device

In this recipe, you’ll adapt the previous recipe to build and run the game on an Apple device attached to your computer with a USB cable.

Getting ready

Before starting this recipe, ensure you have completed the second recipe in this chapter: Setting up your system for Apple iOS mobile app development.

This project follows on from the previous one – we’ll just be changing the build target to Apple iOS, so you can simply open your existing project.

How to do it...

To deploy the Third Person Controller Starter project for an Apple device, perform the following steps:

  1. Open the Third Person Controller Starter project created in the previous recipe.
  2. Open the Build Settings… panel by choosing Edit | Build Settings…. Switch the build platform to iOS (select iOS and click the Switch Platform button). You may need to wait a few minutes for...

Creating and deploying a mobile game with Unity’s Runner Game project template

Unity has published a great Runner Game mobile project template. In this recipe, we’ll create a project with that template, customize the scene, and deploy it to a mobile device.

Figure 16.20: Photos of the mobile Runner Game deployed and running on an Android phone

How to do it...

To create and deploy a mobile runner game with the Runner Game project template, perform the following steps:

  1. Open the Unity Hub application. Click New Project, and select the version of the Unity Editor you wish to develop with.
  2. Locate the Runner Game template in the list of templates (you’ll need to download it the first time you use the template).

Figure 16.21: Selecting the Runner Game project template in Unity Hub

  1. Create and open the new project.
  2. When you open the project, you may wish to explore this tutorial template by clicking through...

Further reading

The following are some useful sources for the topics that were covered in this chapter:

If you wish to publish your games on the Apple App Store or Google Play Store, you’ll need to pay and register as an Android/Apple developer. Learn more here:

Unity Technologies published a free runner game on the Asset Store for Unity 2020. It may still be useful for assets and ideas to inspire a fully...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Unity Cookbook - Fifth Edition
Published in: Nov 2023Publisher: PacktISBN-13: 9781805123026
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.
undefined
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 €14.99/month. Cancel anytime

Authors (3)

author image
Shaun Ferns

Shaun is a lecturer at Technological University Dublin. He is currently teaching on the BA (Hons) in Creative Digital Media where he is lead in the delivery of the Multimedia Stream. He is currently exploring serious games for construction-related training as well as the opportunities transmedia provides in improving user experience and engagement in cultural archive artifacts. His educational research is currently driven by his interest in self-determined learning (heutagogy), rhizomatic learning theory, micro-credentialing /digital badging, and curriculum development.
Read more about Shaun Ferns

author image
Sinéad Murphy

Sinead Murphy is currently Data Analytics Manager for the Irish NGO Trocaire. She has over 25 years of computing experience, including freelance IT training and database consulting, university lecturing in mathematics, IT skills and programming at TU Dublin (Ireland) and Middlesex University (London). She is a published academic, with undergraduate and postgraduate degrees in mathematics, computing and data science. She is passionate about the use of IT for understanding and visualising data, and using that understanding to make meaningful differences in the world. She is currently exploring the use of Python and Unity for data analytics and interactive visualisations.
Read more about Sinéad Murphy