Book description
Are you ready to take your Unity game development skills to the next level? Look no further! The "Unity Cookbook 2023, 5th Edition" is your essential guide to mastering the latest features of Unity 2023, packed with over 140 recipes to empower your game development journey. Purchase of the print or Kindle book includes a free eBook in the PDF format.
Key Features
- Explore VR and AR development to create immersive experiences that redefine gaming
- Craft captivating mobile games with optimized performance and user-friendly controls
- Elevate gameplay with expertly composed music, dynamic sound effects, and seamless audio integration
Book Description
Unleash your game development potential with Unity Cookbook, 5th Edition, designed to equip you with the skills and knowledge needed to excel in Unity game development. With over 160 expertly crafted recipes empowering you to pioneer VR and AR experiences, excel in mobile game development, and become a master of audio techniques.
In this latest edition, we've meticulously curated a collection of recipes that reflect the latest advancements in Unity 2023, ensuring you stay at the forefront of game development. You'll discover dedicated recipes for First/Third Person (Core) templates, create engaging mobile games, delve into Virtual and Augmented Reality, and go further with audio by exploring advanced techniques. Additionally, the book has been fully updated to incorporate the new input system and TextMeshPro, essential elements for modern game development.
From exploring C# scripting to crafting stylish UIs, creating stunning visual effects, and understanding shader development through Shader Graph, every chapter is designed to take you closer to your goal of becoming a proficient Unity developer.
So, whether you're aiming to develop the next hit game, enhance your portfolio, or simply have fun building games, this book will be your trusted companion on your journey to Unity proficiency.
What you will learn
- Craft stylish user interfaces, from power bars to radars, and implement button-driven scene changes effortlessly
- Enhance your games with AI controlled characters, harnessing Unity's navigation meshes, surfaces, and agents
- Discover the power of Cinemachine in Unity for intelligent camera movements
- Elevate games with immersive audio, including background music and dynamic sound effects
- Bring your games to life with captivating visual effects, from smoke and explosions to customizable particle systems
- Build your own shaders using Unity's Shader Graph tool
Who this book is for
If you’re a Unity developer looking for better ways to resolve common recurring problems, then this book is for you. Programmers dipping their toes into multimedia features for the first time will also find this book useful. Before you get started with this book, you’ll need a solid understanding of Unity’s functionality and experience with programming in C#.
Table of contents
- Preface
- Displaying Data with Core UI Elements
-
Responding to User Events for Interactive UIs
- Creating a UI Button to reveal an image
- Creating a UI Button to move between scenes
- Animating UI Button properties on mouseover
- 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 Input Field
- Detecting interactions with a single Toggle UI component
- Creating related radio buttons using UI Toggles
- Creating text UI Dropdown menus
- Creating image icon UI Dropdown menus
- Displaying a radar to indicate the relative locations of objects
- Further reading
-
Inventory and Advanced UIs
- 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 to display scripted components
- 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
- Further reading
- Learn more on Discord
-
Playing and Manipulating Sounds
- Setting up the Third Person Character Controller project
- Playing sound when a scene begins
- Removing redundant AudioListener components
- Enabling and customizing 3D sound effects
- Adding effects with Audio Reverb Zones
- Playing different one-off sound effects with a single AudioSource component
- Playing and controlling different sounds, each with its own AudioSource component
- Creating just-in-time AudioSource components at runtime through C# scripting
- A button to play a sound with no scripting
- Preventing an audio clip from restarting if it is already playing
- Waiting for the audio to finish playing before auto-destructing an object
- Creating audio visualization from sample spectral data
- Synchronizing simultaneous and sequential music to create a simple 140 bpm music-loop manager
- Recording sound clips with the free Audacity application
- Further reading
-
Textures, Materials, and 3D Objects
- Creating a scene with 3D primitives and a texture
- Creating material asset files and setting Albedo textures
- Exporting Blender files as FBX for use in Unity
- Importing FBX models into a Unity project
- Highlighting GameObject materials on mouseover
- Fading the transparency of a material
- Further reading
- Learn more on Discord
- Creating 3D Environments with Terrains
- Creating 3D Geometry with ProBuilder
-
2D Animation and Physics
- 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 the animation from one state to another
- Creating animation clips from sprite sheet sequences
- Creating a platform game with Tiles and Tilemaps
- Using sprite placeholders to create a simple physics scene
- Editing polygon Colliders for more realistic 2D physics
- Creating an explosionForce method for 2D physics objects
- Clipping via Sprite Masking
- Further reading
-
Animated Characters
- Unity’s Third Person Character Controller assets
- Adding a Third Person Character Controller to a scene
- Adding a clothing accessory pickup for a character
- Swapping the Third Person Armature for a different character
- Creating a 3D character with Autodesk Character Generator
- Selecting and downloading a character from Mixamo
- Selecting and downloading an animation clip from Mixamo
- Creating an animated NPC in Unity using a character and animation clip
- Using scripts to control 3D animations (old input system)
- Using scripts to control 3D animations (new input system)
- Further reading
- Learn more on Discord
-
Saving and Loading Data
- Saving data between scenes using static properties
- Saving data between scenes and games using PlayerPrefs
- Reading data from a text file
- Loading game data from a text file map
- Writing data to a file
- Logging player actions and game events to a file
- Reading data from the web
- Setting up a leaderboard using PHP and a database
- Unity game communication with a web server leaderboard
- Further reading
-
Controlling and Choosing Positions
- Using a rectangle to constrain 2D Player object movement
- Player control of a 3D GameObject (and limiting 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
- Further reading
- Learn more on Discord
-
Navigation Meshes and Agents
- 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 sequence
- Creating a movable NavMesh Obstacle
- Joining several NavMeshes with a single NavMeshSurface
- Non-horizontal NavMeshes with multiple NavMeshSurfaces and NavMeshLinks
- Further reading
-
Cameras, Lighting, and Visual Effects
- Creating the basic scene for this chapter
- Working with a fixed Main Camera
- Changing how much of the screen a Camera renders
- Adding a top-down orthographic minimap Camera
- Creating an in-game mirror using a RenderTexture to send Camera output to a Plane
- Saving screenshots and RenderTextures to files
- Using Cinemachine ClearShot to switch cameras to keep the player in shot
- A Camera to always look at and follow the Third Person Controller
- Adding film grain and vignette effects with URP postprocessing
- Creating an HDRP project with an HDRI skybox
- Creating and applying a cookie texture to a spotlight
- Baking light from an emissive material onto other scene GameObjects
- Further reading
- Learn more on Discord
-
Shader Graphs and Video Players
- Playing videos with the Video Player API
- Playing videos by manually adding a VideoPlayer component to a GameObject
- Using scripting to control video playback on scene textures
- Ensuring a movie is prepared before playing
- Outputting video playback to a RenderTexture asset
- Using scripting to play a sequence of videos back to back
- Creating and using a simple shader
- Creating a glow effect with Shader Graph
- Toggling a Shader Graph color glow effect through C# code
- Further reading
-
Particle Systems and Other Visual Effects
- Exploring Unity’s Particle Pack and reusing samples for your own games
- Creating a simple Particle Systems from scratch
- Using Texture Sheets to simulate fire with a Particle System
- Making particles collide with scene objects
- Simulating an explosion
- Using Invoke to delay the execution of an explosion
- Using a Line Renderer to create a spinning laser trap
- Further reading
- Learn more on Discord
-
Mobile Games and Applications
- Setting up your system for Android mobile app development
- Setting up your system for Apple iOS mobile app development
- Deploying the Third Person Character Controller Starter project for an Android device
- Deploying the Third Person Character Controller Starter project for an Apple device
- Creating and deploying a mobile game with Unity’s Runner Game project template
- Further reading
-
Augmented Reality (AR)
- Exploring the Unity AR samples
- Creating an AR project with the AR (Core) template
- Adding the AR Foundation package and GameObjects to a 3D scene
- Detecting and highlighting planes with AR Foundation
- Creating an AR furniture previewer by detecting horizontal planes
- Creating a floating 3D model over an image target
- Further reading
- Learn more on Discord
-
Virtual and Extended Reality (VR/XR)
- Setting up the Oculus Quest 2 for Unity development
- Creating and running a Unity project on a VR headset
- Beginning with the XR Interaction Toolkit
- Creating a 360-degree video VR project
- Exploring and building the Desert WebXR demo project
- Using GitHub Pages to publish your WebXR project for free
- Creating a simple WebXR scene from scratch
- Further reading
-
Advanced Topics – Gizmos, Automated Testing, and More
- Using a gizmo to show the currently selected object in the Scene panel
- Creating an Editor snap-to-grid drawn by a gizmo
- Generating and running a default test script class
- Making a simple unit test
- Parameterizing tests with a DataProvider
- Unit testing a simple health script class
- Creating and executing a unit test in PlayMode
- PlayMode testing a door animation
- PlayMode and unit testing a player health bar with events, logging, and exceptions
- Reporting Code Coverage testing
- Running simple Python scripts inside Unity
- Further reading
- Learn more on Discord
- Other Books You May Enjoy
- Index
Product information
- Title: Unity Cookbook - Fifth Edition
- Author(s):
- Release date: November 2023
- Publisher(s): Packt Publishing
- ISBN: 9781805123026
You might also like
book
Unity in Action, Third Edition
This hands-on beginners guide gets you building games fast, all with the awesome Unity engine! You’ll …
book
Unity Development Cookbook, 2nd Edition
Learn everything you need to know to use the powerful Unity engine to its full potential …
book
Unity Artificial Intelligence Programming - Fifth Edition
Learn and implement game AI in Unity to build smart environments and enemies with A* pathfinding, …
book
Hands-On Unity 2022 Game Development - Third Edition
Create, customize, and optimize your own professional games from scratch with Unity 2022 Includes invitation to …