Book description
Develop quality game components and solve common gameplay problems with various game design patterns
Key Features
- Become proficient at traditional 2D and 3D game development
- Build amazing interactive interfaces with Unity's UI system
- Develop professional games with realistic animation and graphics, materials and cameras, and AI with Unity 2018
Book Description
With the help of the Unity 2018 Cookbook, you'll discover how to make the most of the UI system and understand how to animate both 2D and 3D characters and game scene objects using Unity's Mecanim animation toolsets.
Once you've got to grips with the basics, you will familiarize yourself with shaders and Shader Graphs, followed by understanding the animation features to enhance your skills in building fantastic games. In addition to this, you will discover AI and navigation techniques for nonplayer character control and later explore Unity 2018's newly added features to improve your 2D and 3D game development skills. This book provides many Unity C# gameplay scripting techniques.
By the end of this book, you'll have gained comprehensive knowledge in game development with Unity 2018.
What you will learn
- Get creative with Unity's shaders and learn to build your own shaders with the new Shader Graph tool
- Create a text and image character dialog with the free Fungus Unity plugin
- Explore new features integrated into Unity 2018, including TextMesh Pro and ProBuilder
- Master Unity audio, including ducking, reverbing, and matching pitch to animation speeds
- Work with the new Cinemachine and timeline to intelligently control camera movements
- Improve ambiance through the use of lights and effects, including reflection and light probes
- Create stylish user interfaces with the UI system, including power bars and clock displays
Who this book is for
Unity 2018 Cookbook is for you if you want to explore a wide range of Unity scripting and multimedia features and find ready-to-use solutions for many game features. This book also helps programmers explore multimedia features. It is assumed that you already know basics of Unity and have some programming knowledge of C#.
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- Packt Upsell
- Foreword
- Contributors
- Preface
-
Displaying Data with Core UI Elements
- 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 Mesh
- Creating sophisticated text with TextMeshPro
- Displaying an image
- Creating UIs with the Fungus open source dialog system
- Creating a Fungus character dialog with images
-
Responding to User Events for Interactive UIs
- Introduction
- Creating UI Buttons to move between scenes
- Animating button properties on mouse-over
- Organizing image panels and changing panel depths via buttons
- Displaying the value of an interactive UI Slider
- Displaying a countdown timer graphically with a UI Slider
- Setting custom mouse cursors for 2D and 3D GameObjects
- Setting custom mouse cursors for UI controls
- Interactive text entry with an Input Field
- Toggles and radio buttons via Toggle Groups
- Creating text and image icon UI Dropdown menus
- Displaying a radar to indicate the relative locations of objects
-
Inventory UIs
- 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 multiple status icons
- Using panels to visually outline the inventory UI area and individual items
- Creating a C# inventory slot UI display scripted component
- Using UI Grid Layout Groups to automatically populate a panel
- Displaying multiple pickups of different objects as a list of text via a dynamic List<> of scripted PickUp objects
- Displaying multiple pickups of different objects as text totals via a dynamic Dictionary<> of PickUp objects and enum pickup types
-
Playing and Manipulating Sounds
- Introduction
- Playing different one-off sound effects with a single AudioSource component
- Playing and controlling different sounds each with their own AudioSource component
- Creating just-in-time AudioSource components at runtime through C# scripting
- Delaying before playing a sound
- Preventing an Audio Clip from restarting if it is already playing
- Waiting for the audio to finish playing before auto-destructing an object
- Creating a metronome through the precise scheduling of sounds with dspTime
- Matching the audio pitch to the animation speed
- Simulating acoustic environments with Reverb Zones
- Adding volume control with Audio Mixers
- Making a dynamic soundtrack with Snapshots
- Balancing in-game audio with Ducking
- Audio visualization from sample spectral data
- Synchronizing simultaneous and sequential music to create a simple 140 bpm music-loop manager
-
Creating Textures, 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
-
Shader Graphs and Video Players
- Introduction
- Playing videos by manually adding a VideoPlayer component to a GameObject
- Using scripting to control video playback on scene textures
- Using scripting to play a sequence of videos back-to-back
- Creating and using a simple Shader Graph
- Creating a glow effect with Shader Graph
- Toggling a Shader Graph color glow effect through C# code
-
Using Cameras
- Introduction
- Creating the basic scene for this chapter
- Creating a picture-in-picture effect
- Switching between multiple cameras
- Making textures from screen content
- Zooming a telescopic camera
- Displaying a minimap
- Creating an in-game surveillance Camera
- Working with Unity's multi-purpose camera rig
- Using Cinemachine ClearShot to switch cameras to keep the player in shot
- Letting the player switch to a Cinemachine FreeLook camera
-
Lights and Effects
- Introduction
- Directional Light with cookie Texture to simulate a cloudy day
- Creating and applying a cookie texture to a spotlight
- Adding a custom Reflection map to a scene
- Creating a laser aim with a projector
- Enhancing the laser aim with a Line Renderer
- Setting up an environment with Procedural Skybox and Directional Light
- Reflecting surrounding objects with Reflection Probes
- Using Material Emission to bake light from a glowing lamp onto scene objects
- Lighting a simple scene with Lightmaps and Light Probes
-
2D Animation
- Introduction
- Flipping a sprite horizontally – the DIY approach
- Flipping a sprite horizontally – using Animator State Chart and Transitions
- Animating body parts for character movement events
- Creating a three-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
- Creating a platform game with Tiles and Tilemaps
- Creating a game with the 2D Gamekit
-
3D Animation
- 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 scripts
- 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
- Creating geometry with Probuilder
- Creating a game with the 3D Gamekit
- Importing third-party 3D models and animations from Mixamo
-
Webserver Communication and Online Version-Control
- Introduction
- Setting up a leaderboard using PHP and a database
- Unity game communication with web-server leaderboard
- Creating and cloning a GitHub repository
- Adding a Unity project to a local Git repository, and pushing files up to GitHub
- Unity project version-control using GitHub for Unity
- Preventing your game from running on unknown servers
-
Controlling and Choosing Positions
- 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 – finding a random spawn point
- Choosing destinations – finding the nearest spawn point
- Choosing destinations – respawning to the most recently passed checkpoint
- Moving objects by clicking on them
- Firing projectiles in the direction of movement
-
Navigation Meshes and Agents
- Introduction
- NPC to travel to destination while avoiding obstacles
- NPC to seek or flee from a moving object
- Point-and-click move to object
- Point-and-click move to tile
- Point-and-click Raycast with user-defined higher-cost Navigation Areas
- NPC NavMeshAgent to follow waypoints in a sequence
- Controlling object group movement through flocking
- Creating a movable NavMesh Obstacle
- Design Patterns
-
Editor Extensions and Immediate Mode GUI (IMGUI)
- Introduction
- Menu items to log messages and clear the console
- Displaying a panel with text data
- An interactive panel with persistent storage
- Creating GameObjects, parenting, and registering Undo actions
- Working with selected objects and deactivating menu items
- Menu item to create 100 randomly positioned prefab clones
- A progress bar to display proportion completed of Editor extension processing
- An editor extension to allow pickup type (and parameters) to be changed at design time via a custom Inspector UI
- An editor extension to have an object-creator GameObject, with buttons to instantiate different pickups at cross-hair object location in scene
- Extensible class-based code architecture to manage complex IMGUIs
-
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 or StreamingAssets folders
- Saving Project files into Unity Asset Bundles
- Loading resources from Unity Asset Bundles
-
Working with Plain Text, XML, and JSON Text Files
- Introduction
- Loading external text files using the TextAsset public variable
- Loading external text files using C# file streams
- Saving external text files with C# file streams
- Loading and parsing external XML
- Creating XML text data manually using XMLWriter
- Saving and loading XML text data automatically through serialization
- Creating XML text files – saving XML directly to text files with XMLDocument.Save()
- Creating JSON strings from individual objects and lists of objects
- Creating individual objects and Lists of objects from JSON strings
-
Virtual Reality and Extra Features
- Introduction
- Saving screenshots from the game
- Saving and loading player data – using static properties
- Saving and loading player data – using PlayerPrefs
- Loading game data from a text file map
- UI Slider to change game quality settings
- Pausing the game
- Implementing slow motion
- Using Gizmo to show the currently selected object in a scene panel
- Editor snap-to grid drawn by Gizmo
- Creating a VR project
- Adding 360-degree videos to a VR project
- Working with VR content inside a VR environment – the XR Editor
-
Automated Testing
- Introduction
- Generating a default test script class
- A simple unit test
- Parameterizing tests with a data provider method
- Unit testing a simple health script class
- Creating and executing a unit test in Play mode
- PlayMode testing a door animation
- PlayMode and Unit Testing a player health bar with events, logging, and exceptions
- Bonus Chapters
- Other Books You May Enjoy
Product information
- Title: Unity 2018 Cookbook - Third Edition
- Author(s):
- Release date: August 2018
- Publisher(s): Packt Publishing
- ISBN: 9781788471909
You might also like
book
Unity 2018 By Example - Second Edition
Build exciting 2D/3D games and virtual reality applications with the help of hands-on examples Key Features …
book
Unity 2018 Shaders and Effects Cookbook
Bring realism to your games by mastering post-processing effects and advanced shading techniques in Unity 2018 …
book
Building an RPG with Unity 2018
Build a high-end, multiplayer role-playing game (RPG) from scratch with C# and Unity 2018 Key Features …
book
Unity 5.x Cookbook
Over 100 recipes exploring the new and exciting features of Unity 5 to spice up your …