This is the code repository for Unity Cookbook, Fifth Edition, published by Packt.
The authors of this book are - Matt Smith, Shaun Ferns and Sinéad Murphy
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.
- 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 your 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
- Displaying Data with Core UI Elements
- Responding to User Events for Interactive UIs
- Inventory and Advanced UIs
- Playing and Manipulating Sounds
- Textures, Materials, and 3D Objects
- Creating 3D Environments with Terrains
- Creating 3D Geometry with ProBuilder
- 2D Animation and Physics
- Animated Characters
- Saving and Loading Data
- Controlling and Choosing Positions
- Navigation Meshes and Agents
- Cameras, Lighting, and Visual Effects
- Shader Graphs and Video Players
- Particle Systems and Other Visual Effects
- Mobile Games and Applications
- Augmented Reality (AR)
- Virtual and Extended Reality (VR/XR)
- Advanced Topics – Gizmos, Automated Testing, and More
For all chapters, you will need Unity 2023.1 or later, plus one of the following computer systems:
- Microsoft Windows 10 (64-bit)/GPU: DX10, DX11, and DX12-capable
- macOS GPU Metal-capable Intel or AMD
- Mojave 10.14+ / Intel x64 with SSE2 instruction set support
- Big Sur 11.0 / Apple Silicon M1 or later
- Linux Ubuntu 20.04 or Ubuntu 18.04 / Gnome desktop running on X11 / GPU: OpenGL 3.2+ or Vulkan-capable Nvidia or AMD For each chapter, there is a folder in the book’s GitHub repository that contains the asset files you will need; you can find these at https://github.com/PacktPublishing/Unity-2023-Cookbook-Fifth-Edition.
For recipes in some chapters, additional hardware/software will be helpful:
-
Chapter 4, Playing and Manipulating Sounds
To edit and create audio files yourself, you can download and install the free Audacity application for your computer system (Windows/Mac/Linux). You can find it at https://www.audacityteam.org/download/.
-
Chapter 5, Textures, Materials, and 3D Objects
To work with 3D objects in the Blender editor, you can download it for free at www.blender.org.
-
Chapter 10, Saving and Loading Data
Since some of the recipes in this chapter make use of web servers and a database, for those recipes, you will require either the PHP 8 language (which comes with its own web server and SQLite database features) or an AMP package.
- If you are installing the PHP language, refer to the installation guide and download links:
- If you do want to install a web server and database server application, a great choice is XAMPP. It is a free, cross-platform collection of everything you need to set up a database and web server on your local computer. The download page also contains FAQs and installation instructions for Windows, Mac, and Linux: https://www.apachefriends.org/download.html.
-
Chapter 15, Particle Systems and Other Visual Effects
If you wish to create your own image files, you will also need an image editor, such as Adobe Photoshop, which can be found at www.adobe.com, or GIMP, which is a free alternative and can be found at www.gimp.org/.
-
Chapter 16, Mobile Games and Apps
- If developing for Android, you’ll need an Android mobile device.
- If developing for Apple iOS, you’ll need:
- An Apple iOS mobile device.
- A free Apple ID, which you can create on an Apple device or at https://appleid.apple.com/.
- A Mac computer with the free Xcode program editor installed.
- Note: If you don’t have access to a Mac computer and Xcode, another way to develop for Apple iOS is to use Unity’s Cloud Build services. Learn more about Cloud Build for iOS at https://docs.unity3d.com/2020.1/Documentation/Manual/UnityCloudBuildiOS.html.
-
Chapter 17, Augmented Reality (AR)
To get the most from this chapter’s recipes, you will need an AR device. For this, you can use a dedicated device such as an AR headset, or you can use smartphone apps to begin experiencing AR.
-
Chapter 18, Virtual Reality (VR) and Extended Reality (XR)
You will need a device to view VR apps. For this, you can use a dedicated device, such as a VR headset like the Meta Quest 1/2/3, Samsung Gear VR, or Apple Vision Pro. If you wish to use a smartphone for VR projects, there are many low-cost devices to choose from, such as Google Cardboard: https://developers.google.com/cardboard
Matt Smith is senior lecturer at TU Dublin, the Technological University of Dublin, Ireland, specialising in XR and interactive multimedia. He leads the university’s DRIVE (Digital Realities, Interaction, and Virtual Environments) research group, and is currently supervising several PhD students in interaction design and XR technologies. In 1980, Matt started computer programming (on a ZX80). A few years later he submitted his first two games for the programming project component of his ‘O’-level computing certificate (aged 16). In 1985, Matt wrote the lyrics, and was a member of the band that played (and sang, sorry about that by the way) the music on the B-side of the audio cassette carrying the computer game Confuzion (the game/song has a Wikipedia page...). In 2024, No Starch Press will publish his PHP Crash Course. Matt is still (pleasantly!) surprised at the popularity of his Unity Cookbook series – whose beginning was a book proposal sent to Packt Publishing over 10 years ago.
Shaun Ferns is an academic at TU Dublin, the Technological University of Dublin, Ireland, where he is a researcher in the DRIVE (Digital Realities, Interaction, and Virtual Environments) research group and an associate researcher at the Educational Informatics Lab (EILab) at OntarioTechU. Since 2016, he has been primarily researching and teaching multimedia development, and prior to that was involved in the delivery of several engineering programs. He is currently exploring the opportunities transmedia provides in improving user experience and engagement in cultural archive artifacts and serious games for the built environment. Shaun began to “play” with Unity when designing and building his house in 2010, developing an architectural walk-through to support the development of the design of the new home. Since then, he has been working on several Unity-based cultural projects and hopes to complete one soon! Shaun has taken up the challenge of playing the Irish tenor banjo and currently enjoys playing in Irish traditional music sessions with his friends. When not practicing, he can be found wandering the cliffs and mountains around Donegal or swimming its Atlantic shores.
Sinéad Murphy is currently Data Analytics Manager for the Irish NGO Trócaire. She has over 25 years of computing experience, including freelance IT training and database consulting, university lecturing in mathematics, IT skills, and programming at TU Dublin (Ireland) and Middlesex University (London). She is a published academic, with undergraduate and postgraduate degrees in mathematics, computing, and data science. She is passionate about the use of IT for understanding and visualising data, and using that understanding to make meaningful differences in the world. She is currently exploring the use of Python and Unity for data analytics and interactive visualisations.