Unity 5.x Cookbook (Paperback)

Matt Smith, Chico Queiroz



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

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.

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

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.

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.


《Unity 5 遊戲開發食譜》是一本探索 Unity 5 新功能的書籍,提供超過 100 個食譜,幫助你提升 Unity 技能。


  • 本書基於廣受歡迎的 Unity 4.x Cookbook,完全更新為 Unity 5 版本

  • 提供 2D 和 3D 遊戲的食譜

  • 介紹 Unity 5 的新功能,包括新的 UI 系統、2D 遊戲開發、新的標準着色器和新的音頻混音器



程式設計師可以探索多媒體功能,多媒體開發者可以嘗試腳本編寫。基本的 Unity 平台知識、遊戲設計原則和 C# 編程知識是必要的。


  • 利用 Unity 5 的音頻功能,包括新的音頻混音器、混響區域的環境音效、快照的動態配樂和壓制技術,提供出色的音效體驗

  • 使用 Unity 的新物理着色器創建更好的材質

  • 測量和控制時間,包括遊戲暫停、顯示時鐘和倒計時器,甚至實現「子彈時間」效果

  • 通過燈光和效果(如反射和光探針)改善遊戲氛圍

  • 使用新的 UI 系統創建時尚的用戶界面,包括能量條、時鐘顯示和可擴展的庫存系統

  • 從本地或遠程源保存和加載文本和媒體資源,通過 Unity Cloud 發布遊戲,並與網站及其數據庫通信以創建在線排行榜

  • 探索高級技術,包括發布-訂閱和狀態模式、性能瓶頸識別以及最大化遊戲性能和幀率的方法

  • 控制 2D 和 3D 角色移動,使用 NavMeshAgents 編寫 NPC 和敵人的行為,如尋找、逃跑、群集和路徑跟隨


Unity 5 是一個靈活且直觀的多平台遊戲引擎,已成為業界的事實標準。通過學習核心概念,如動畫、音頻、着色器、GUI、燈光、攝像機和腳本編寫,使用 Unity 5 打造自己的 2D 和 3D 電腦遊戲。

本書完全重寫以涵蓋 Unity 5 的新功能,對於所有 Unity 遊戲開發者來說都是一個很好的資源,從剛開始使用 Unity 的人到 Unity 專業人士。

本書的前半部分著重於 2D 遊戲設計的核心概念,後半部分則著重於開發 3D 遊戲的技能。在前半部分,你將了解新的 GUI 系統、新的音頻混音器、外部文件和在 2D 遊戲開發中為 2D 角色添加動畫。隨著進一步的學習,你將熟悉新的標準着色器、Mecanim 系統、攝像機和新的燈光功能,以完善你的 3D 遊戲開發技能。最後,你將學習非玩家角色控制,並探索 Unity 5 的其他功能,以提升你的 3D 遊戲開發技能。


每一章首先介紹主題領域,並解釋所涵蓋技術如何增強你的遊戲。每個食譜都提供逐步指示,然後解釋其工作原理,並提供有用的附加改進或替代方法。每個所需的資源和 C# 腳本(完全註釋)都可以下載,讓你能夠按照每個食譜進行操作。