Book Image

Unity 5 for Android Essentials

By : Valera Cogut
Book Image

Unity 5 for Android Essentials

By: Valera Cogut

Overview of this book

Table of Contents (14 chapters)
Unity 5 for Android Essentials
About the Author
About the Reviewers


Learn the Unity 5 engine to master designing and building awesome real-world games and applications for Android devices. Design beautiful effects, animations, physical behaviors, and other different real-world features and techniques for your Android games and applications. Optimize your project and any other real-world projects for Android devices. Know more in practice about accessing Android functionality, rendering high-end graphics, expanding your project using asset bundles, and of course learn about deploying on the Android platform and much more.

Unity is essentially a development environment for multiple platforms (Android, iOS, Blackberry, Windows Phone, Windows, Playstation, Xbox, Mac, Linux, and Web). Unity is a very popular and effective technology for creating 2D and 3D games and applications. This technology provides many useful and effective tools to solve various issues. The Unity rendering engine provides great real-time rendering of high-quality graphics without too much cost and effort.

The Android platform and game industry is developing like never before. Most programmers using Unity, especially those new to the technology, would like to learn to recreate different functional parts from the most popular real-world games and applications that will cause a great concern in the community.

Whether you are new to Unity 5 or an expert, this book will provide you with the required skills you need to successfully design, implement, build, and enhance the quality of your Android game or application. By sequentially working through the steps in each chapter, you will quickly master the key features of the Unity 5 engine to implement real-world Android games and application features in practice.

This book is aimed for competent Unity developers who want to learn to develop, optimize, and publish games for Android devices. Know more about the Unity 5 engine to build awesome real-world Android games.

Starting from the beginning, this book will explain the configuration of the Unity 5 settings for the Android platform. Implement the innovative and user-friendly features using real-world techniques and tips and tricks in practice. Explore how to improve your Android games and enhance its performance. Open a wonderful world of rendering high-quality graphics with physically-based shaders and global illumination. Discover Android features inside the Unity 5 engine and more about transformation from native C# and JavaScript codes into Unity scripts.

This book is aimed at covering the fundamentals relating to typical real-world games and applications and to explore a basic overview of the concepts but the focus is on providing the practical skills required to develop Android games and applications.

Unity 5 for Android Essentials will teach you to use different tools provided by the Unity Technologies team in order to master your game's design and development processes. This book will be a practical guidebook that will help you to leverage the Unity 5 framework in order to build awesome games and apps for Android devices.

What this book covers

Chapter 1, Setting Up and Configuring an Android Platform, explains how to configure Unity 5 for Android devices. Also in this chapter, we will explore about APK expansion files in Unity 5. At the end of the chapter, you will build a very simple and basic game example for Android devices.

Chapter 2, Accessing Android Functionality, covers how to create plugins for the Android platform using Java and C languages in Unity 5. The reader will learn in practice how to write simple plugins for the Android platform. Also, the reader will learn to make anti-piracy checks, detect screen orientation, handle vibration support, determine device generation, and do more useful things.

Chapter 3, High-end Graphics for Android Devices, primarily explores how to enhance the quality in games and applications using physically-based shaders. This chapter will also describe global illumination in Unity 5. At the end of the chapter, you will optimize a shader code.

Chapter 4, Animation, Audio, Physics, and Particle Systems in Unity 5, will cover new Mecanim animation features in Unity 5. After that, you will learn awesome new audio features in Unity 5. At the end of this chapter, you will explore physics and particle systems in Unity 5.

Chapter 5, Asset Bundles in Unity 5 Pro, includes an overview of asset bundles in Unity 5. You will learn to download new code and data in real time for Android devices. At the end of this chapter, you will discover the safety technique of the asset bundles in practice.

Chapter 6, Optimization and Transformation Techniques, introduces the usage of occlusion culling and optimization techniques for the level of detail. You will learn to optimize Unity C# and Unity JS code. Finally, you will see how to transform Unity C# code to Unity JavaScript code and vice versa.

Chapter 7, Troubleshooting and Best Practices, covers the optimization of any game for Android devices and teaches you to find any bottlenecks. In this chapter, you will discover some troubleshooting techniques for the Android platform. At the end of this chapter, you will learn the best practices that are used by many professionals from all over the world for their scripts and shaders.

The online chapter, Developing Glow Hockey from Scratch, shows you how easy it is to develop the most popular game in the Android Market (Glow Hockey has about 100,000,000–500,000,000 installs in Unity 5 from scratch. Also, you will learn to optimize your project and any other real-world projects for Android devices. Many more useful details and features will be covered in this chapter. You can find this chapter at

What you need for this book

You need the following software for this book:

  • Windows or Mac OS X

  • Java Development Kit (JDK)

  • Android SDK

  • Unity3D

Who this book is for

This book is for readers that have a basic knowledge of the architecture of Unity, programming plus shading, and for those who are expert Unity developers. This book is very helpful for anybody who wants quick solutions and answers for many different questions and issues while developing a game or application in Unity.

Perhaps you already know a bit about the Unity 5 engine, but have never used it before; or perhaps, you know programming but are new to using Unity 5 to develop Android games and applications. In all cases, this book will quickly teach you to master high-quality Android games and applications. This book is for anyone who wants to explore a wide range of Unity features and finds ready-to-use techniques, solutions, tips and tricks that are used all over the world. It is best for you if you have basic experience with C# or JavaScript and feel comfortable enough with the Unity workflow.

Whether you've developed games before or not, and you're just looking to get started in Unity to make new fantastic real-world games and applications, this book will help you. This book is for you and everyone in your team, from beginners to expert developers!


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

using UnityEngine;

public class YourClassName: MonoBehaviour {
  void OnCollisionExit (Collision collision) {
    Debug.Log ("OnCollisionExit :" +;

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

using UnityEngine;

public class YourClassName: MonoBehaviour {
  void OnCollisionExit (Collision collision) {
    Debug.Log ("OnCollisionExit :" +;

Any command-line input or output is written as follows:

# cp /usr/src/asterisk-addons/configs/cdr_mysql.conf.sample

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Clicking on the Next button moves you to the next screen."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via 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 on

Customer support

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.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


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 would 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, 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 on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


Piracy of copyright 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 with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.