O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unity 5 for Android Essentials

Book Description

A fast-paced guide to building impressive games and applications for Android devices with Unity 5

About This Book

  • Design beautiful effects, animations, physical behaviors, and other different real-world features for your Android games and applications
  • Optimize your project and any other real-world projects for Android devices
  • Follows a tutorial-based approach to learning the best practices for accessing Android functionality, rendering high-end graphics, and expanding your project using Asset Bundles

Who This Book Is For

This book is perfect for competent Unity developers who want to learn how to develop, optimize, and publish games for Android devices in a quick and easy manner. This book assumes basic knowledge of game design concepts and/or some experience with other game technologies such as Unreal Engine 4, CryEngine, or GameMaker.

What You Will Learn

  • Discover tips and tricks to optimize Unity scripts
  • Create Java and native C plugins for the Android platform
  • Access Android features and sensors inside the Unity 5 engine
  • Render high quality graphics and optimize Cg shaders
  • Play Legacy and Mecanim animations in Unity 5
  • Download new assets and code behavior while your game is running on an Android device in order to expand your game in real time
  • Debug your games and applications on Android devices using the Unity Profiler tool

In Detail

Unity is a very popular and effective technology for creating 2D and 3D games and applications. The Unity rendering engine provides great real-time rendering of high quality graphics without too much cost and effort. It boasts industry leading multi-platform support and world class monetization and retention services for mobile games, making it the first choice for many game developers across the world. Unity 5 is a great starting point for game developers looking to develop stunning and robust games.

Starting with a refresher on the basics of Unity 5, this book will take you all the way through to creating your first custom game. By the end of the book, you will understand how to work with all the aspects of Unity 5. You will quickly explore all the major key features of the Unity 5 engine and learn to implement real-world Android game and application features in practice.

We begin by introducing how to set up the Android SDK on Windows and Mac OS X and configure Unity 5 settings for the Android platform. As you progress through the chapters, you will learn to implement innovative and user-friendly features with the aid of real-world examples. You will explore how to render high quality graphics with physically-based shaders and global illumination to enhance your project's performance. Building on this, you will then learn to transform your native C# and JavaScript code into Unity scripts. Best practices to improve your Android games will also be discussed to help you create games fast and efficiently. Finally, putting together all these concepts, you will learn to create your own Android game from scratch.

This book will teach you how to harness the benefits of different tools to become proficient at game design and development processes.

Style and approach

This book is a simple and fast-paced guide that helps you through the process of creating real-world Android games and applications with the Unity engine using step-by-step and practical examples that progressively build upon each other.

Table of Contents

  1. Unity 5 for Android Essentials
    1. Table of Contents
    2. Unity 5 for Android Essentials
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Setting Up and Configuring an Android Platform
      1. Configuring Unity 5 for Android devices
      2. APK expansion files in Unity 5
        1. Overview
        2. Formats
        3. The updating process
        4. Setting up expansion files in Unity 5
      3. Building for Android devices
      4. Unity License Comparison Overview
        1. NavMeshes, pathfinding, and crowd simulation
        2. Level of Detail (LOD) support
        3. Audio filters
        4. Video playback and streaming
        5. Full-fledged streaming with asset bundles
        6. Hundred thousand dollar turnover
        7. Mecanim – IK Rigs
        8. Mecanim – sync layers and additional curves
        9. Custom splash screen
        10. Build size stripping
        11. Lightmapping with global illumination and area lights
        12. HDR and tone mapping
        13. Occlusion culling
        14. Light probes
        15. Static batching
        16. Render-to-texture effects
        17. Fullscreen postprocessing effects
        18. NavMesh – dynamic obstacles and priority
        19. .NET socket support
        20. Profiler and GPU profiling
        21. Real-time directional shadows
        22. Script access to asset pipeline
      5. Summary
    9. 2. Accessing Android Functionality
      1. Creating Java and native C plugins for an Android platform
        1. Creating plugins in C
        2. Creating plugins in Java (Eclipse IDE)
          1. Writing Java code in plugin
          2. Turning on and off a hardware flashlight
          3. On Unity side
          4. Exporting and importing a JAR library from Eclipse into Unity
          5. Importing AndroidManifest
          6. Using Java plugins in Unity scripts
        3. Anti-piracy check
        4. Vibration
        5. Activity Indicator
        6. Screen orientation
        7. System information
      2. Accessing the Android sensors and features within Unity 5
        1. Acceleration
        2. Gyroscope
        3. Compass
      3. Summary
    10. 3. High-end Graphics for Android Devices
      1. Physically-based shaders
        1. Basic shader concepts
          1. The vertex shader
          2. The geometry shader
          3. The pixel/fragment shader
        2. Shading languages
          1. Cg
          2. Unity shaders in Cg
        3. A custom diffuse lighting model
          1. A basic reflection environment
          2. Masked texture reflection
        4. Lighting model techniques
          1. The Lit sphere model
        5. Realistic rendering
      2. Global illumination
      3. Practicing in shader optimization
        1. Best case practice
      4. Summary
    11. 4. Animation, Audio, Physics, and Particle Systems in Unity 5
      1. New Mecanim animation features in Unity 5
        1. State machine behavior
        2. State machine transition
        3. Asset creation API
        4. Direct blend tree
        5. Programmatically creating assets by Unity 5 API
          1. Creating the controller
          2. Adding parameters
          3. Adding state machines
          4. Adding states
          5. Adding transitions
        6. Going deeper into new audio features
        7. Mood transitions
      2. Physics and particle system effects in Unity 5
        1. Particle system performance tips and tricks
          1. Legacy versus Shuriken Unity's built-in particle systems
          2. Particle system tips
      3. Summary
    12. 5. Asset Bundles in Unity 5 Pro
      1. An overview of the asset bundles in Unity 5
      2. Downloading new code and data in real time for Android devices
        1. Managing loaded asset bundles
        2. Asset bundles and binary data
        3. Asset bundles and scripts
        4. Asset bundle dependencies
      3. Safeness techniques in practice
      4. Summary
    13. 6. Optimization and Transformation Techniques
      1. Occlusion culling and level of detail in optimization techniques
        1. Optimizing by LOD
      2. Unity C# and Unity JS optimization tips and tricks
      3. Transforming Unity C# code into Unity JavaScript code and vice versa
        1. JavaScript variables and types
        2. C# variables and types
        3. Converting types in Unity JS
        4. Converting types in Unity C#
        5. Unity JS function versus Unity C# function
        6. Unity JS return versus Unity C# return
        7. Unity JS yielding versus Unity C# yielding
        8. Unity JS directives versus Unity C# directives
      4. Summary
    14. 7. Troubleshooting and Best Practices
      1. Measuring performance with the built-in Android profiler
        1. General CPU activity
        2. Rendering statistics
        3. Detailed Unity player statistics
        4. Detailed script statistics
        5. Detailed statistics on memory allocated by scripts
      2. Debugging Android devices with the Unity profiler tool
        1. Profiler timeline
        2. The CPU area
        3. The Rendering area
        4. The Memory area
          1. The simple view
          2. The detailed view
        5. The audio area
        6. The physics area
        7. The GPU area
      3. Real-practice techniques
        1. The high-speed, off-screen particles technique in Unity
        2. The pool technique
      4. The scriptable profiler tool
        1. Unity profiler tricks
        2. Creating a simple profiler
      5. Summary
    15. Index