Book description
Over 100 recipes exploring the new and exciting features of Unity 5 to spice up your Unity skillset
About This Book
- Built on the solid foundation of the popular Unity 4.x Cookbook, the recipes in this edition have been completely updated for Unity 5
- Features recipes for both 2D and 3D games
- Provides you with techniques for the new features of Unity 5, including the new UI system, 2D game development, new Standard Shaders, and the new Audio Mixer
In Detail
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 Unity 5.
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 Unity professionals.
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.
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
Who This Book Is For
From beginners to advanced users, from artists to coders, this book is for you and everyone in your team!
Programmers can explore multimedia features, and multimedia developers can try their hand at scripting. Basic knowledge and understanding of the Unity platform, game design principles, and programming knowledge in C# is essential.
Style and approach
Each chapter first introduces the topic area and explains how the techniques covered can enhance your games. Every recipe provides step-by-step instructions, followed by an explanation of how it all works, and useful additional refinements or alternative approaches. Every required resource and C# script (fully commented) is available to download, enabling you to follow each recipe yourself.
Table of contents
-
Unity 5.x Cookbook
- Table of Contents
- Unity 5.x Cookbook
- Credits
- Foreword
- About the Authors
- About the Reviewers
- www.PacktPub.com
- Preface
-
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
-
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
-
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
-
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
- 5. Using Cameras
-
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
-
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
-
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
-
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
-
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
-
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
-
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
- Index
Product information
- Title: Unity 5.x Cookbook
- Author(s):
- Release date: October 2015
- Publisher(s): Packt Publishing
- ISBN: 9781784391362
You might also like
book
Unity 5.x Animation Cookbook
A recipe-based guide to give you practical information on Unity 5.x animation techniques and tools About …
book
Unity 5.x By Example
An example-based practical guide to get you up and running with Unity 5.x About This Book …
book
Unity 2018 Cookbook - Third Edition
Develop quality game components and solve common gameplay problems with various game design patterns Key Features …
book
Unity 4 Fundamentals
Get ahead of the game with Unity 4. The Unity engine is the tool of choice …