Unity 5.x Cookbook

Everything you need to tackle Unity programming can be found in this collection of more than 100 Unity 5 recipes, packed with game development tips and tricks

Unity 5.x Cookbook

Cookbook
Matt Smith, Chico Queiroz

17 customer reviews
Everything you need to tackle Unity programming can be found in this collection of more than 100 Unity 5 recipes, packed with game development tips and tricks
$43.99
$54.99
RRP $43.99
RRP $54.99
eBook
Print + eBook

Instantly access this course right now and get the skills you need in 2017

With unlimited access to a constantly growing library of over 4,000 eBooks and Videos, a subscription to Mapt gives you everything you need to get that next promotion or to land that dream job. Cancel anytime.

Free Sample

Book Details

ISBN 139781784391362
Paperback570 pages

Book Description

Unity 5 is a flexible and intuitive multiplatform game engine that is becoming the industry’s de facto standard. Learn to craft your own 2D and 3D computer games by working through core concepts such as animation, audio, shaders, GUI, lights, cameras, and scripting to create your own games with one of the most important and popular engines in the industry.

Completely re-written to cover the new features of Unity 5, this book is a great resource for all Unity game developers, from those who have recently started using Unity right up to game development experts.

The first half of the book focuses on core concepts of 2D game design while the second half focuses on developing 3D game development skills. In the first half, you will discover the new GUI system, the new Audio Mixer, external files, and animating 2D characters in 2D game development. As you progress further, you will familiarize yourself with the new Standard Shaders, the Mecanim system, Cameras, and the new Lighting features to hone your skills towards building 3D games to perfection. Finally, you will learn non-player character control and explore Unity 5's extra features to enhance your 3D game development skills.

Table of Contents

Chapter 1: Core UI – Messages, Menus, Scores, and Timers
Introduction
Displaying a "Hello World" UI text message
Displaying a digital clock
Displaying a digital countdown timer
Creating a message that fades away
Displaying a perspective 3D text message
Displaying an image
Creating UI Buttons to move between scenes
Organizing images inside panels and changing panel depths via buttons
Displaying the value of an interactive UI Slider
Displaying a countdown timer graphically with a UI Slider
Displaying a radar to indicate the relative locations of objects
Creating UIs with the Fungus open-source dialog system
Setting custom mouse cursor images
Input Fields component for text entry
Toggles and radio buttons via Toggle Groups
Conclusion
Chapter 2: Inventory GUIs
Introduction
Creating a simple 2D mini-game – SpaceGirl
Displaying single object pickups with carrying and not-carrying text
Displaying single object pickups with carrying and not-carrying icons
Displaying multiple pickups of the same object with text totals
Displaying multiple pickups of the same object with multiple status icons
Revealing icons for multiple object pickups by changing the size of a tiled image
Displaying multiple pickups of different objects as a list of text via a dynamic List<> of PickUp objects
Displaying multiple pickups of different objects as text totals via a dynamic Dictionary<> of PickUp objects and "enum" pickup types
Generalizing multiple icon displays using UI Grid Layout Groups (with scrollbars!)
Conclusion
Chapter 3: 2D Animation
Introduction
Flipping a sprite horizontally
Animating body parts for character movement events
Creating a 3-frame animation clip to make a platform continually animate
Making a platform start falling once stepped-on using a Trigger to move animation from one state to another
Creating animation clips from sprite sheet sequences
Conclusion
Chapter 4: Creating Maps and Materials
Introduction
Creating a basic material with Standard Shader (Specular setup)
Adapting a basic material from Specular setup to Metallic
Applying Normal maps to a material
Adding Transparency and Emission maps to a material
Highlighting materials at mouse over
Adding Detail maps to a material
Fading the transparency of a material
Playing videos inside a scene
Conclusion
Chapter 5: Using Cameras
Introduction
Creating a picture-in-picture effect
Switching between multiple cameras
Making textures from screen content
Zooming a telescopic camera
Displaying a mini-map
Creating an in-game surveillance camera
Chapter 6: Lights and Effects
Introduction
Using lights and cookie textures to simulate a cloudy day
Adding a custom Reflection map to a scene
Creating a laser aim with Projector and Line Renderer
Reflecting surrounding objects with Reflection Probes
Setting up an environment with Procedural Skybox and Directional Light
Lighting a simple scene with Lightmaps and Light Probes
Conclusion
Chapter 7: Controlling 3D Animations
Introduction
Configuring a character's Avatar and idle animation
Moving your character with root motion and Blend Trees
Mixing animations with Layers and Masks
Organizing States into Sub-state Machines
Transforming the Character Controller via script
Adding rigid props to animated characters
Using Animation Events to throw an object
Applying Ragdoll physics to a character
Rotating the character's torso to aim a weapon
Chapter 8: Positions, Movement and Navigation for Character GameObjects
Introduction
Player control of a 2D GameObject (and limiting the movement within a rectangle)
Player control of a 3D GameObject (and limiting the movement within a rectangle)
Choosing destinations – find the nearest (or a random) spawn point
Choosing destinations – respawn to the most recently passed checkpoint
NPC NavMeshAgent to seek or flee destination while avoiding obstacles
NPC NavMeshAgent to follow the waypoints in a sequence
Controlling the object group movement through flocking
Conclusion
Chapter 9: Playing and Manipulating Sounds
Introduction
Matching the audio pitch to the animation speed
Simulating acoustic environments with Reverb Zones
Preventing an Audio Clip from restarting if it is already playing
Waiting for audio to finish playing before auto-destructing an object
Adding volume control with Audio Mixers
Making a dynamic soundtrack with Snapshots
Balancing in-game audio with Ducking
Chapter 10: Working with External Resource Files and Devices
Introduction
Loading external resource files – using Unity Default Resources
Loading external resource files – by downloading files from the Internet
Loading external resource files – by manually storing files in the Unity Resources folder
Saving and loading player data – using static properties
Saving and loading player data – using PlayerPrefs
Saving screenshots from the game
Setting up a leaderboard using PHP/MySQL
Loading game data from a text file map
Managing Unity project code using Git version control and GitHub hosting
Publishing for multiple devices via Unity Cloud
Chapter 11: Improving Games with Extra Features and Optimization
Introduction
Pausing the game
Implementing slow motion
Preventing your game from running on unknown servers
State-driven behavior Do-It-Yourself states
State-driven behavior using the State Design pattern
Reducing the number of objects by destroying objects at death a time
Reducing the number of enabled objects by disabling objects whenever possible
Reducing the number of active objects by making objects inactive whenever possible
Improving efficiency with delegates and events and avoiding SendMessage!
Executing methods regularly but independent of frame rate with coroutines
Spreading long computations over several frames with coroutines
Evaluating performance by measuring max and min frame rates (FPS)
Identifying performance bottlenecks with the Unity performance Profiler
Identifying performance "bottlenecks" with Do-It-Yourself performance profiling
Cache GameObject and component references to avoid expensive lookups
Improving performance with LOD groups
Improving performance through reduced draw calls by designing for draw call batching
Conclusion
Chapter 12: Editor Extensions
Introduction
An editor extension to allow pickup type (and parameters) to be changed at design time via a custom Inspector UI
An editor extension to add 100 randomly located copies of a prefab with one menu click
A progress bar to display proportion completed of Editor extension processing
An editor extension to have an object-creator GameObject, with buttons to instantiate different pickups at cross-hair object location in scene
Conclusion

What You Will Learn

  • Immerse players with great audio, utilizing Unity 5's audio features including the new Audio Mixer, ambient sound with Reverb Zones, dynamic soundtracks with Snapshots, and balanced audio via Ducking
  • Create better materials with Unity’s new, physically-based, Standard Shader
  • Measure and control time, including pausing the game, displaying clocks and countdown timers, and even implementing “bullet time” effects
  • Improve ambiance through the use of lights and effects such as reflection and light probes
  • Create stylish user interfaces with the new UI system, including power-bars, clock displays, and an extensible inventory system
  • Save and load text and media assets from local or remote sources, publish your game via Unity Cloud, and communicate with websites and their databases to create online scoreboards
  • Discover advanced techniques, including the publisher-subscriber and state patterns, performance bottleneck identification, and methods to maximize game performance and frame rates
  • Control 2D and 3D character movement, and use NavMeshAgents to write NPC and enemy behaviors such as seek, flee, flock, and waypoint path following

Authors

Table of Contents

Chapter 1: Core UI – Messages, Menus, Scores, and Timers
Introduction
Displaying a "Hello World" UI text message
Displaying a digital clock
Displaying a digital countdown timer
Creating a message that fades away
Displaying a perspective 3D text message
Displaying an image
Creating UI Buttons to move between scenes
Organizing images inside panels and changing panel depths via buttons
Displaying the value of an interactive UI Slider
Displaying a countdown timer graphically with a UI Slider
Displaying a radar to indicate the relative locations of objects
Creating UIs with the Fungus open-source dialog system
Setting custom mouse cursor images
Input Fields component for text entry
Toggles and radio buttons via Toggle Groups
Conclusion
Chapter 2: Inventory GUIs
Introduction
Creating a simple 2D mini-game – SpaceGirl
Displaying single object pickups with carrying and not-carrying text
Displaying single object pickups with carrying and not-carrying icons
Displaying multiple pickups of the same object with text totals
Displaying multiple pickups of the same object with multiple status icons
Revealing icons for multiple object pickups by changing the size of a tiled image
Displaying multiple pickups of different objects as a list of text via a dynamic List<> of PickUp objects
Displaying multiple pickups of different objects as text totals via a dynamic Dictionary<> of PickUp objects and "enum" pickup types
Generalizing multiple icon displays using UI Grid Layout Groups (with scrollbars!)
Conclusion
Chapter 3: 2D Animation
Introduction
Flipping a sprite horizontally
Animating body parts for character movement events
Creating a 3-frame animation clip to make a platform continually animate
Making a platform start falling once stepped-on using a Trigger to move animation from one state to another
Creating animation clips from sprite sheet sequences
Conclusion
Chapter 4: Creating Maps and Materials
Introduction
Creating a basic material with Standard Shader (Specular setup)
Adapting a basic material from Specular setup to Metallic
Applying Normal maps to a material
Adding Transparency and Emission maps to a material
Highlighting materials at mouse over
Adding Detail maps to a material
Fading the transparency of a material
Playing videos inside a scene
Conclusion
Chapter 5: Using Cameras
Introduction
Creating a picture-in-picture effect
Switching between multiple cameras
Making textures from screen content
Zooming a telescopic camera
Displaying a mini-map
Creating an in-game surveillance camera
Chapter 6: Lights and Effects
Introduction
Using lights and cookie textures to simulate a cloudy day
Adding a custom Reflection map to a scene
Creating a laser aim with Projector and Line Renderer
Reflecting surrounding objects with Reflection Probes
Setting up an environment with Procedural Skybox and Directional Light
Lighting a simple scene with Lightmaps and Light Probes
Conclusion
Chapter 7: Controlling 3D Animations
Introduction
Configuring a character's Avatar and idle animation
Moving your character with root motion and Blend Trees
Mixing animations with Layers and Masks
Organizing States into Sub-state Machines
Transforming the Character Controller via script
Adding rigid props to animated characters
Using Animation Events to throw an object
Applying Ragdoll physics to a character
Rotating the character's torso to aim a weapon
Chapter 8: Positions, Movement and Navigation for Character GameObjects
Introduction
Player control of a 2D GameObject (and limiting the movement within a rectangle)
Player control of a 3D GameObject (and limiting the movement within a rectangle)
Choosing destinations – find the nearest (or a random) spawn point
Choosing destinations – respawn to the most recently passed checkpoint
NPC NavMeshAgent to seek or flee destination while avoiding obstacles
NPC NavMeshAgent to follow the waypoints in a sequence
Controlling the object group movement through flocking
Conclusion
Chapter 9: Playing and Manipulating Sounds
Introduction
Matching the audio pitch to the animation speed
Simulating acoustic environments with Reverb Zones
Preventing an Audio Clip from restarting if it is already playing
Waiting for audio to finish playing before auto-destructing an object
Adding volume control with Audio Mixers
Making a dynamic soundtrack with Snapshots
Balancing in-game audio with Ducking
Chapter 10: Working with External Resource Files and Devices
Introduction
Loading external resource files – using Unity Default Resources
Loading external resource files – by downloading files from the Internet
Loading external resource files – by manually storing files in the Unity Resources folder
Saving and loading player data – using static properties
Saving and loading player data – using PlayerPrefs
Saving screenshots from the game
Setting up a leaderboard using PHP/MySQL
Loading game data from a text file map
Managing Unity project code using Git version control and GitHub hosting
Publishing for multiple devices via Unity Cloud
Chapter 11: Improving Games with Extra Features and Optimization
Introduction
Pausing the game
Implementing slow motion
Preventing your game from running on unknown servers
State-driven behavior Do-It-Yourself states
State-driven behavior using the State Design pattern
Reducing the number of objects by destroying objects at death a time
Reducing the number of enabled objects by disabling objects whenever possible
Reducing the number of active objects by making objects inactive whenever possible
Improving efficiency with delegates and events and avoiding SendMessage!
Executing methods regularly but independent of frame rate with coroutines
Spreading long computations over several frames with coroutines
Evaluating performance by measuring max and min frame rates (FPS)
Identifying performance bottlenecks with the Unity performance Profiler
Identifying performance "bottlenecks" with Do-It-Yourself performance profiling
Cache GameObject and component references to avoid expensive lookups
Improving performance with LOD groups
Improving performance through reduced draw calls by designing for draw call batching
Conclusion
Chapter 12: Editor Extensions
Introduction
An editor extension to allow pickup type (and parameters) to be changed at design time via a custom Inspector UI
An editor extension to add 100 randomly located copies of a prefab with one menu click
A progress bar to display proportion completed of Editor extension processing
An editor extension to have an object-creator GameObject, with buttons to instantiate different pickups at cross-hair object location in scene
Conclusion

Book Details

ISBN 139781784391362
Paperback570 pages
Read More
From 17 reviews

Read More Reviews