Unity Cookbook - Fifth Edition

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

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. Technical requirements to get the most out of this book
    4. Get in touch
  2. Displaying Data with Core UI Elements
    1. Creating a Font Asset file for use with TextMeshPro
      1. Getting ready
      2. How to do it...
      3. How it works...
    2. Displaying a “Hello World” UI text message
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Styling substrings with rich text
        2. Exploring the TextMeshPro Examples and Extras
    3. Displaying a digital clock
      1. Getting ready
      2. How to do it…
      3. How it works...
    4. Displaying a digital countdown timer
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Automatically add components with [RequireComponent(...)]
    5. Creating a message that fades away
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Displaying an image
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Working with 2D sprites and UI Image components
      5. See also
    7. Further reading
    8. Learn more on Discord
  3. Responding to User Events for Interactive UIs
    1. Creating a UI Button to reveal an image
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    2. Creating a UI Button to move between scenes
      1. How to do it...
      2. How it works...
      3. There’s more...
    3. Animating UI Button properties on mouseover
      1. How to do it...
      2. How it works...
    4. Organizing image panels and changing panel depths via buttons
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Moving up or down by just one position, using scripted methods
    5. Displaying the value of an interactive UI Slider
      1. How to do it...
      2. How it works...
    6. Displaying a countdown timer graphically with a UI Slider
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Setting custom mouse cursors for 2D and 3D GameObjects
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Setting custom mouse cursors for UI controls
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Interactive text entry with Input Field
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    10. Detecting interactions with a single Toggle UI component
      1. Getting ready
      2. How to do it...
      3. How it works...
    11. Creating related radio buttons using UI Toggles
      1. Getting ready
      2. How to do it...
      3. How it works...
    12. Creating text UI Dropdown menus
      1. How to do it...
      2. How it works...
    13. Creating image icon UI Dropdown menus
      1. Getting ready
      2. How to do it...
      3. How it works...
    14. Displaying a radar to indicate the relative locations of objects
      1. Getting ready
      2. How to do it...
      3. How it works...
        1. The Start() method
        2. The Update() method
        3. The FindAndDisplayBlipsForTag(...) method
        4. The CalculateBlipPositionAndDrawBlip (...) method
        5. The NormalizedPosition(...) method
        6. The CalculateBlipPosition(...) method
        7. The DrawBlip() method
      4. There’s more...
    15. Further reading
  4. Inventory and Advanced UIs
    1. Creating a simple 2D mini-game – SpaceGirl
      1. Getting ready
      2. How to do it...
      3. How it works...
    2. Displaying single object pickups with carrying and not-carrying text
      1. Getting ready
      2. How to do it...
      3. How it works...
        1. The PlayerInventory script class
        2. The PlayerInventoryDisplay script class
      4. There’s more...
        1. Collecting multiple items and displaying the total number carried
        2. Alternative – combining all the responsibilities into a single script
    3. Displaying single-object pickups with carrying and not-carrying icons
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Displaying multiple pickups of the same object with multiple status icons
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Revealing icons for multiple object pickups by changing the size of a tiled image
      5. How it works...
    5. Using panels to visually outline the inventory UI area and individual items
      1. Getting ready
      2. How to do it…
      3. How it works...
    6. Creating a C# inventory slot UI to display scripted components
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Modifying the game for a second inventory panel for keys
    7. Displaying multiple pickups of different objects as a list of text via a dynamic List<> of scripted PickUp objects
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Ordering items in the inventory list alphabetically
    8. Displaying multiple pickups of different objects as text totals via a dynamic Dictionary<> of PickUp objects and enum pickup types
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Separating responsibilities with MVC
    9. Further reading
    10. Learn more on Discord
  5. Playing and Manipulating Sounds
    1. Setting up the Third Person Character Controller project
      1. How to do it...
      2. How it works...
      3. There’s more...
        1. Fixing pink textures
    2. Playing sound when a scene begins
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Create a GameObject with AudioSource linked to an AudioClip in a single step
        2. Make the sound clip keep looping
        3. Customizing other AudioSource settings
    3. Removing redundant AudioListener components
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Enabling and customizing 3D sound effects
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Changing the way the volume changes with distance
        2. Adding keys to customize the volume falloff curve
    5. Adding effects with Audio Reverb Zones
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Customize Reverb settings with the User preset
    6. Playing different one-off sound effects with a single AudioSource component
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Playing a sound at a static point in 3D world space
    7. Playing and controlling different sounds, each with its own AudioSource component
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Creating just-in-time AudioSource components at runtime through C# scripting
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Adding the CreateAudioSource(...) method as an extension to the MonoBehavior class
    9. A button to play a sound with no scripting
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Preventing an audio clip from restarting if it is already playing
      1. Getting ready
      2. How to do it...
      3. How it works...
    11. Waiting for the audio to finish playing before auto-destructing an object
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    12. Creating audio visualization from sample spectral data
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Adding visualizations to a second AudioSource component
        2. Trying out different Fast Fourier Transform (FFT) window types
    13. Synchronizing simultaneous and sequential music to create a simple 140 bpm music-loop manager
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Adding visualizations to the four playing loops
    14. Recording sound clips with the free Audacity application
      1. Getting ready
      2. How to do it...
      3. How it works...
    15. Further reading
  6. Textures, Materials, and 3D Objects
    1. Creating a scene with 3D primitives and a texture
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Enhancing the scene – adding a spotlight
    2. Creating material asset files and setting Albedo textures
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Exporting Blender files as FBX for use in Unity
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Importing FBX models into a Unity project
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Using Blender files directly in a Unity project
    5. Highlighting GameObject materials on mouseover
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. A collider needed for custom meshes
        2. Changing the material’s color in response to mouse events
    6. Fading the transparency of a material
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Destroying objects when fading is complete
        2. Using the GameObject’s alpha as our starting alpha value
        3. Using a coroutine for our fading loop
    7. Further reading
    8. Learn more on Discord
  7. Creating 3D Environments with Terrains
    1. Creating and texture-painting terrains
      1. Getting ready
      2. How to do it...
      3. How it works...
    2. Unity terrain tools and samples for powerful height-painting
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more…
    3. Adding terrain holes
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Adding trees and vegetation
      1. Getting ready
      2. How to do it…
      3. How it works...
    5. Realistic water features for HDRP projects
      1. How to do it...
      2. How it works...
    6. Further reading
  8. Creating 3D Geometry with ProBuilder
    1. Getting started with ProBuilder
      1. Getting ready
      2. How to do it...
      3. How it works...
    2. Transforming an object through scaling and coloring
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Creating a house with ProBuilder
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Exploring ProBuilder Boolean operations to add a window to our house
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Organizing level geometry as empty GameObject children
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Further reading
    7. Learn more on Discord
  9. 2D Animation and Physics
    1. Flipping a sprite horizontally – the DIY approach
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    2. Flipping a sprite horizontally – using Animator State chart and transitions
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Instantaneous swapping
    3. Animating body parts for character movement events
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating a three-frame animation clip to make a platform continually animate
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Copying the animation relative to a new parent GameObject
    5. Making a platform start falling once stepped on using a Trigger to move the animation from one state to another
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating animation clips from sprite sheet sequences
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Creating a platform game with Tiles and Tilemaps
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Tile palettes for objects and walls
    8. Using sprite placeholders to create a simple physics scene
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Editing polygon Colliders for more realistic 2D physics
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Creating an explosionForce method for 2D physics objects
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    11. Clipping via Sprite Masking
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    12. Further reading
  10. Animated Characters
    1. Unity’s Third Person Character Controller assets
      1. How to do it...
      2. How it works...
    2. Adding a Third Person Character Controller to a scene
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Adding a clothing accessory pickup for a character
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Swapping the Third Person Armature for a different character
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Extracting textures when colors are not showing
    5. Creating a 3D character with Autodesk Character Generator
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Replace the robot character with your created character
        2. Remove the Light child GameObject from the character Hierarchy
    6. Selecting and downloading a character from Mixamo
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Using Mixamo to convert and fix character models
    7. Selecting and downloading an animation clip from Mixamo
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Creating an animated NPC in Unity using a character and animation clip
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Using scripts to control 3D animations (old input system)
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Using scripts to control 3D animations (new input system)
      1. Getting ready
      2. How to do it...
      3. How it works...
    11. Further reading
    12. Learn more on Discord
  11. Saving and Loading Data
    1. Saving data between scenes using static properties
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Hiding the score before the first attempt is completed
      5. See also
    2. Saving data between scenes and games using PlayerPrefs
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Reading data from a text file
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Loading game data from a text file map
      1. How to do it...
      2. How it works...
    5. Writing data to a file
      1. How to do it...
      2. How it works...
      3. There’s more...
        1. Writing lists of objects to a JSON text file
    6. Logging player actions and game events to a file
      1. How to do it...
      2. How it works...
      3. There’s more...
        1. Automatically log the username of the system user
      4. See also
    7. Reading data from the web
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Setting up a leaderboard using PHP and a database
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. SQLite, PHP, and database servers
        2. phpLiteAdmin
      5. See also
    9. Unity game communication with a web server leaderboard
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Extracting the full leaderboard data for display within Unity
        2. Using secret game codes to secure your leaderboard scripts
    10. Further reading
  12. Controlling and Choosing Positions
    1. Using a rectangle to constrain 2D Player object movement
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Drawing a gizmo yellow rectangle to visually show a bounding rectangle
        2. An alternative approach to defining movement bounds
    2. Player control of a 3D GameObject (and limiting movement within a rectangle)
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Drawing a thick gizmo yellow rectangle to visually show a bounding rectangle
    3. Choosing destinations – finding a random spawn point
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Choosing destinations – finding the nearest spawn point
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Avoiding errors due to an empty array
      5. See also
    5. Choosing destinations – respawning to the most recently passed checkpoint
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Moving objects by clicking on them
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Firing projectiles in the direction of movement
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Further reading
    9. Learn more on Discord
  13. Navigation Meshes and Agents
    1. NPC to travel to destination while avoiding obstacles
      1. Getting ready
      2. How to do it...
      3. How it works...
    2. NPC to seek or flee from a moving object
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Using a Debug Ray to show a source-to-destination line
        2. Constantly updating the NavMeshAgent’s destination to flee from the player’s current location
        3. Maintaining a constant distance from the target (“lurking” mode!)
    3. Point-and-click move to object
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Creating a mouseover yellow highlight
    4. Point-and-click move to tile
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Using a yellow Debug Ray to show the destination of the AI agent
    5. Point-and-click raycast with user-defined, higher-cost navigation areas
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. More intelligent pathfinding by setting different costs for custom-defined navigation areas such as mud and water
        2. Improving the UX by updating a “gaze” cursor in each frame
    6. NPC NavMeshAgent to follow waypoints in sequence
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Working with arrays of waypoints
        2. Increased flexibility with the WayPoint class
    7. Creating a movable NavMesh Obstacle
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Joining several NavMeshes with a single NavMeshSurface
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Non-horizontal NavMeshes with multiple NavMeshSurfaces and NavMeshLinks
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Further reading
  14. Cameras, Lighting, and Visual Effects
    1. Creating the basic scene for this chapter
      1. Getting ready
      2. How to do it…
      3. How it works...
      4. There’s more...
        1. Fixing pink textures
    2. Working with a fixed Main Camera
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Changing how much of the screen a Camera renders
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Adding a top-down orthographic minimap Camera
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Adding a floating arrow to indicate the direction the player is facing in the minimap
        2. Using a culling mask to avoid the sphere being rendered unintentionally
    5. Creating an in-game mirror using a RenderTexture to send Camera output to a Plane
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Inverting our mirror Camera horizontally
    6. Saving screenshots and RenderTextures to files
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Automate screenshot capture with OnTriggerEnter()
        2. Capture screenshots as a Texture or RenderTexture
    7. Using Cinemachine ClearShot to switch cameras to keep the player in shot
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. A Camera to always look at and follow the Third Person Controller
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Adding the option to switch between a following camera and multiple ClearShot cameras
    9. Adding film grain and vignette effects with URP postprocessing
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Adding a vignette effect
    10. Creating an HDRP project with an HDRI skybox
      1. Getting ready
      2. How to do it…
      3. How it works...
      4. There’s more...
        1. Using a skybox for default ground image
    11. Creating and applying a cookie texture to a spotlight
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Adding more content and creating ground shadows
        2. Using Cookies with Directional Lights
    12. Baking light from an emissive material onto other scene GameObjects
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Emissive materials that do not contribute to lighting other objects in the scene
    13. Further reading
    14. Learn more on Discord
  15. Shader Graphs and Video Players
    1. Playing videos with the Video Player API
    2. Playing videos by manually adding a VideoPlayer component to a GameObject
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    3. Using scripting to control video playback on scene textures
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Downloading an online video (rather than a clip)
    4. Ensuring a movie is prepared before playing
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Outputting video playback to a RenderTexture asset
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Using scripting to play a sequence of videos back to back
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Creating and using a simple shader
      1. How to do it...
      2. How it works...
    8. Creating a glow effect with Shader Graph
      1. Getting ready
      2. How to do it...
      3. How it works...
    9. Toggling a Shader Graph color glow effect through C# code
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    10. Further reading
      1. Shader Graph online resources
      2. Video player online resources
  16. Particle Systems and Other Visual Effects
    1. Exploring Unity’s Particle Pack and reusing samples for your own games
      1. How to do it...
      2. How it works...
    2. Creating a simple Particle Systems from scratch
      1. How to do it...
      2. How it works...
    3. Using Texture Sheets to simulate fire with a Particle System
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Making particles collide with scene objects
      1. How to do it...
      2. How it works...
      3. There’s more...
    5. Simulating an explosion
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Using Invoke to delay the execution of an explosion
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Destroying or damaging objects in a bomb blast radius
        2. Adding camera shake when the bomb explodes
    7. Using a Line Renderer to create a spinning laser trap
      1. How to do it...
      2. How it works...
      3. There’s more...
        1. Triggering an explosion when the player’s character collides with the beam
    8. Further reading
    9. Learn more on Discord
  17. Mobile Games and Applications
    1. Setting up your system for Android mobile app development
      1. How to do it...
      2. How it works...
    2. Setting up your system for Apple iOS mobile app development
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Deploying the Third Person Character Controller Starter project for an Android device
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Changing the name of the app as it appears on a device
        2. Copying APK files from a Windows PC to an Android device
        3. Sideloading APK files from a Mac to an Android device
        4. Downloading Android APK files on your phone
    4. Deploying the Third Person Character Controller Starter project for an Apple device
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. The device will not prepare for development
    5. Creating and deploying a mobile game with Unity’s Runner Game project template
      1. How to do it...
      2. How it works...
    6. Further reading
  18. Augmented Reality (AR)
    1. Exploring the Unity AR samples
      1. How to do it...
      2. How it works...
    2. Creating an AR project with the AR (Core) template
      1. How to do it...
      2. How it works...
      3. There’s more...
        1. Deprecation warnings with the AR (Core) template
        2. Build failure due to Vulkan graphics API settings
        3. Build failure due to Android version
        4. Building for Apple iOS
    3. Adding the AR Foundation package and GameObjects to a 3D scene
      1. How to do it...
      2. How it works...
    4. Detecting and highlighting planes with AR Foundation
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating an AR furniture previewer by detecting horizontal planes
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating a floating 3D model over an image target
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Further reading
    8. Learn more on Discord
  19. Virtual and Extended Reality (VR/XR)
    1. Setting up the Oculus Quest 2 for Unity development
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Speed up Windows development with Oculus Link/Air Link
        2. Oculus Link is not possible on most Macs
        3. Oculus Link Linux
        4. Online guides to help you set up your Quest for VR development with Unity
    2. Creating and running a Unity project on a VR headset
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
        1. Cannot choose the Quest device due to Android tools unknown location
        2. Build failure due to Android version
        3. Build failure due to “namespace cannot be found” error
    3. Beginning with the XR Interaction Toolkit
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating a 360-degree video VR project
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Exploring and building the Desert WebXR demo project
      1. How to do it...
      2. How it works...
      3. There’s more...
        1. Fixing pink (shader/material) problems
        2. The OpenUPM community maintains more up-to-date XR resources
        3. Latest releases from De-Panther
        4. Missing packages error
    6. Using GitHub Pages to publish your WebXR project for free
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Creating a simple WebXR scene from scratch
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Further reading
  20. Advanced Topics – Gizmos, Automated Testing, and More
    1. Using a gizmo to show the currently selected object in the Scene panel
      1. How to do it...
      2. How it works...
    2. Creating an Editor snap-to-grid drawn by a gizmo
      1. How to do it...
      2. How it works...
      3. There’s more...
    3. Generating and running a default test script class
      1. How to do it...
      2. How it works...
      3. There’s more...
        1. Creating a default test script from the Project window’s Create menu
        2. EditMode minimum skeleton unit test script
    4. Making a simple unit test
      1. How to do it...
      2. How it works...
      3. There’s more...
        1. Shorter tests with values in the assertion
        2. Expected value followed by the actual value
    5. Parameterizing tests with a DataProvider
      1. How to do it...
      2. How it works...
    6. Unit testing a simple health script class
      1. How to do it...
      2. How it works...
        1. Health.cs
        2. TestHealth.cs
    7. Creating and executing a unit test in PlayMode
      1. How to do it...
      2. How it works...
    8. PlayMode testing a door animation
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There’s more...
    9. PlayMode and unit testing a player health bar with events, logging, and exceptions
      1. Getting ready
      2. How to do it...
      3. How it works...
        1. PlayMode testing
        2. Unit tests
      4. See also
    10. Reporting Code Coverage testing
      1. Getting ready
      2. How to do it...
      3. How it works...
    11. Running simple Python scripts inside Unity
      1. How to do it...
      2. How it works...
    12. Further reading
    13. Learn more on Discord
  21. Other Books You May Enjoy
  22. Index

Product information

  • Title: Unity Cookbook - Fifth Edition
  • Author(s): Matt Smith, Shaun Ferns, Sinéad Murphy
  • Release date: November 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781805123026