万本电子书0元读

万本电子书0元读

顶部广告

Unity 5.x Cookbook电子书

售       价:¥

20人正在读 | 0人评论 6.2

作       者:Matt Smith

出  版  社:Packt Publishing

出版时间:2015-10-05

字       数:353.9万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Over 100 recipes exploring the new and exciting features of Unity 5 to spice up your Unity skillsetAbout This BookBuilt on the solid foundation of the popular Unity 4.x Cookbook, the recipes in this edition have been completely updated for Unity 5Features recipes for both 2D and 3D gamesProvides 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 *ing. Basic knowledge and understanding of the Unity platform, game design principles, and programming knowledge in C# is essential.What You Will LearnImmerse 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 DuckingCreate better materials with Unity’s new, physically-based, Standard ShaderMeasure and control time, including pausing the game, displaying clocks and countdown timers, and even implementing “bullet time” effectsImprove ambiance through the use of lights and effects such as reflection and light probesCreate stylish user interfaces with the new UI system, including power-bars, clock displays, and an extensible inventory systemSave 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 scoreboardsDiscover advanced techniques, including the publisher-subscriber and state patterns, performance bottleneck identification, and methods to maximize game performance and frame ratesControl 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 *ing 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# * (fully commented) is available to download, enabling you to follow each recipe yourself.
目录展开

Unity 5.x Cookbook

Table of Contents

Unity 5.x Cookbook

Credits

Foreword

About the Authors

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

Preface

What this book covers

What you need for this book

Who this book is for

Sections

Getting ready

How to do it…

How it works…

There's more…

See also

Conventions

Reader feedback

Customer support

Downloading the example codes and color images

Errata

Piracy

Questions

1. Core UI – Messages, Menus, Scores, and Timers

Introduction

The big picture

Displaying a "Hello World" UI text message

Getting ready

How to do it...

How it works...

There's more...

Styling substrings with Rich Text

Displaying a digital clock

Getting ready

How to do it...

How it works...

There's more...

The Unity tutorial for animating an analogue clock

Displaying a digital countdown timer

Getting ready

How to do it...

How it works...

Creating a message that fades away

Getting ready

How to do it...

How it works...

Displaying a perspective 3D text message

Getting ready

How to do it...

How it works...

There's more...

We have to make this text crawl like it does in the movie

Where to learn more

Displaying an image

Getting ready

How to do it...

How it works...

There's more...

Working with Sprites and UI Image components

See also

Creating UI Buttons to move between scenes

How to do it...

How it works...

There's more...

Visual animation for the button mouse-over

Animating button properties on mouse over

Organizing images inside panels and changing panel depths via buttons

Getting ready

How to do it...

How it works...

There's more...

Moving up or down by just one position, using scripted methods

Displaying the value of an interactive UI Slider

How to do it...

How it works...

Displaying a countdown timer graphically with a UI Slider

Getting ready

How to do it...

How it works...

Displaying a radar to indicate the relative locations of objects

Getting ready

How to do it...

How it works...

The Start() method

The Update() method

The FindAndDisplayBlipsForTag(…) method

The NormalisedPosition(…) method

The CalculateBlipPosition(…) method

The DrawBlip() method

Creating UIs with the Fungus open-source dialog system

How to do it...

How it works...

Setting custom mouse cursor images

Getting ready

How to do it...

How it works...

There's more...

Custom cursors for mouse over UI controls

Input Fields component for text entry

How to do it...

How it works...

There's more...

Executing a C# method to respond each time the user changes the input text content

Toggles and radio buttons via Toggle Groups

Getting ready

How to do it...

How it works...

There's more...

Adding more Toggles and a Toggle Group to implement mutually-exclusive radio buttons

Conclusion

2. Inventory GUIs

Introduction

The big picture

Creating a simple 2D mini-game – SpaceGirl

Getting ready

How to do it...

How it works...

Displaying single object pickups with carrying and not-carrying text

Getting ready

How to do it...

How it works...

There's more...

The separation of view logic

Displaying single object pickups with carrying and not-carrying icons

Getting ready

How to do it...

How it works...

Displaying multiple pickups of the same object with text totals

Getting ready

How to do it...

How it works...

Displaying multiple pickups of the same object with multiple status icons

Getting ready

How to do it...

How it works...

Revealing icons for multiple object pickups by changing the size of a tiled image

Getting ready

How to do it...

How it works...

Displaying multiple pickups of different objects as a list of text via a dynamic List<> of PickUp objects

Getting ready

How to do it...

How it works...

There's more...

Order items in the inventory list alphabetically

Displaying multiple pickups of different objects as text totals via a dynamic Dictionary<> of PickUp objects and "enum" pickup types

Getting ready

How to do it...

How it works...

Generalizing multiple icon displays using UI Grid Layout Groups (with scrollbars!)

Getting ready

How to do it...

How it works...

There's more...

Add a horizontal scrollbar to the inventory slot display

The automation of PlayerInventoryDisplay getting references to all the slots

Automatically changing the grid cell size based on the number of slots in inventory

Add some help methods to the Rect Transform script class

Conclusion

3. 2D Animation

Introduction

The big picture

Flipping a sprite horizontally

Getting ready

How to do it...

How it works...

Animating body parts for character movement events

Getting ready

How to do it...

How it works...

Creating a 3-frame animation clip to make a platform continually animate

Getting ready

How to do it...

How it works...

Making a platform start falling once stepped-on using a Trigger to move animation from one state to another

Getting ready

How to do it...

How it works...

Creating animation clips from sprite sheet sequences

Getting ready

How to do it...

How it works...

Conclusion

4. Creating Maps and Materials

Introduction

Creating and saving texture maps

The big picture

Specular workflow

The metallic workflow

Other material properties

Unity samples and documentation

Creating a basic material with Standard Shader (Specular setup)

Getting ready

How to do it...

How it works...

There's more...

Setting the texture type for an image file

Combining the map with color

Adapting a basic material from Specular setup to Metallic

Getting ready

How to do it...

How it works...

Applying Normal maps to a material

Getting ready

How to do it...

How it works...

There's more...

Adding Transparency and Emission maps to a material

Getting ready

How to do it...

How it works...

There's more...

Using texture maps with Transparent Mode

Avoiding issues with the semi-transparent objects

Emitting light over other objects

Highlighting materials at mouse over

Getting ready

How to do it...

How it works...

There's more...

Adding Detail maps to a material

Getting ready

How to do it...

How it works...

Fading the transparency of a material

How to do it...

How it works...

There's more...

Playing videos inside a scene

Getting ready

How to do it...

How it works...

There's more...

Conclusion

Resources

References

Tools

5. Using Cameras

Introduction

The big picture

Creating a picture-in-picture effect

Getting ready

How to do it...

How it works...

There's more...

Making the picture-in-picture proportional to the screen's size

Changing the position of the picture-in-picture

Preventing the picture-in-picture from updating on every frame

See also

Switching between multiple cameras

Getting ready

How to do it...

How it works...

There's more...

Using a single-enabled camera

Triggering the switch from other events

See also

Making textures from screen content

Getting ready

How to do it...

How it works...

There's more...

Applying your texture to a material

Using your texture as a screenshot

See also

Zooming a telescopic camera

Getting ready...

How to do it...

How it works...

There's more...

Displaying a mini-map

Getting ready...

How to do it...

How it works...

There's more...

Covering a wider or narrower area

Changing the map's orientation

Adapting your mini-map to other styles

Creating an in-game surveillance camera

Getting ready

How to do it...

How it works...

6. Lights and Effects

Introduction

The big picture

Lights

Environment Lighting

Emissive materials

Projector

Lightmaps and Light Probes

The Lighting window

Using lights and cookie textures to simulate a cloudy day

Getting ready

How to do it...

How it works...

There's more...

Creating Spot Light cookies

Creating Point Light Cookies

Adding a custom Reflection map to a scene

Getting ready

How to do it...

How it works...

There's more...

Mapping coordinates

Sharp reflections

Maximum size

Creating a laser aim with Projector and Line Renderer

Getting ready

How to do it...

How it works...

Reflecting surrounding objects with Reflection Probes

Getting ready

How to do it...

How it works...

There's more...

Setting up an environment with Procedural Skybox and Directional Light

Getting ready

How to do it...

How it works...

Lighting a simple scene with Lightmaps and Light Probes

Getting ready

How to do it...

How it works...

There's more...

Conclusion

7. Controlling 3D Animations

Introduction

The big picture

Configuring a character's Avatar and idle animation

Getting ready

How to do it...

How it works...

There's more...

Moving your character with root motion and Blend Trees

Getting ready

How to do it...

How it works...

There's more...

Mixing animations with Layers and Masks

Getting ready

How to do it...

How it works...

There's more...

Organizing States into Sub-state Machines

Getting ready

How to do it...

How it works...

Transforming the Character Controller via script

Getting ready

How to do it...

How it works...

Adding rigid props to animated characters

Getting ready

How to do it...

How it works...

There's more...

Using Animation Events to throw an object

Getting ready

How to do it...

How it works...

Applying Ragdoll physics to a character

Getting ready

How to do it...

How it works...

There's more...

Rotating the character's torso to aim a weapon

Getting ready

How to do it...

How it works...

There's more...

8. Positions, Movement and Navigation for Character GameObjects

Introduction

The big picture

Player control of a 2D GameObject (and limiting the movement within a rectangle)

Getting ready

How to do it...

How it works...

See also

Player control of a 3D GameObject (and limiting the movement within a rectangle)

How to do it...

How it works...

Choosing destinations – find the nearest (or a random) spawn point

Getting ready

How to do it...

How it works...

There's more...

Choosing the nearest spawn point

Avoiding errors due to an empty array

See also

Choosing destinations – respawn to the most recently passed checkpoint

Getting ready

How to do it...

How it works...

NPC NavMeshAgent to seek or flee destination while avoiding obstacles

Getting ready

How to do it...

How it works...

There's more...

Constantly updating the NavMeshAgent destination to Player's character current location

Constantly update NavMeshAgent destination to flee away from Player's character current location

Create a mini point-and-click game

NPC NavMeshAgent to follow the waypoints in a sequence

Getting ready

How to do it...

How it works...

There's more...

More efficient to avoid using NavMeshes for waypoints

Working with arrays of waypoints

Increased flexibility with a WayPoint class

Controlling the object group movement through flocking

Getting ready

How to do it...

How it works...

There's more...

Learn more about flocking Artificial Intelligence

Conclusion

9. Playing and Manipulating Sounds

Introduction

The big picture

Matching the audio pitch to the animation speed

Getting ready

How to do it...

How it works...

There's more...

Changing the Animation/Sound Ratio

Accessing the function from other scripts

Simulating acoustic environments with Reverb Zones

Getting ready

How to do it...

How it works...

There's more...

Attaching the Audio Reverb Zone component to Audio Sources

Making your own Reverb settings

Preventing an Audio Clip from restarting if it is already playing

Getting ready

How to do it...

How it works...

See also

Waiting for audio to finish playing before auto-destructing an object

Getting ready

How to do it...

How it works...

See also

Adding volume control with Audio Mixers

Getting ready

How to do it...

How it works...

There's more...

Playing with Audio Production

See also

Making a dynamic soundtrack with Snapshots

Getting ready

How to do it...

How it works...

There's more...

Reducing the need for multiple audio clips

Dealing with audio file formats and compression rates

Applying Snapshots to background noise

Getting creative with effects

See also

Balancing in-game audio with Ducking

Getting ready

How to do it...

How it works...

See also

10. Working with External Resource Files and Devices

Introduction

The big picture

Loading external resource files – using Unity Default Resources

Getting ready

How to do it...

How it works...

There's more...

Loading text files with this method

Loading and playing audio files with this method

See also

Loading external resource files – by downloading files from the Internet

Getting ready

How to do it...

How it works...

There's more...

Converting from Texture to Sprite

Downloading a text file from the Web

The WWW class and the resource contents

See also

Loading external resource files – by manually storing files in the Unity Resources folder

Getting ready

How to do it...

How it works...

There's more...

Avoiding cross-platform problems with Path.Combine() rather than "/" or "\"

See also

Saving and loading player data – using static properties

Getting ready

How to do it...

How it works...

There's more...

Hiding the score before the first attempt completed

See also

Saving and loading player data – using PlayerPrefs

Getting ready

How to do it...

How it works...

See also

Saving screenshots from the game

Getting ready

How to do it...

How it works...

There's more...

Setting up a leaderboard using PHP/MySQL

Getting ready

How to do it...

How it works...

There's more...

Extracting the full leaderboard data as XML for display within Unity

Using the secret game codes to secure your leaderboard scripts

See also

Loading game data from a text file map

Getting ready

How to do it...

How it works...

Managing Unity project code using Git version control and GitHub hosting

Getting ready

How to do it...

How it works...

There's more...

Learn more about Distributed Version Control Systems (DVCS)

Using Bitbucket and SourceTree

Using the command line rather than Git-client application

See also

Publishing for multiple devices via Unity Cloud

Getting ready

How to do it...

How it works...

There's more...

Learn more about Unity Cloud

See also

11. Improving Games with Extra Features and Optimization

Introduction

The big picture

Pausing the game

Getting ready

How to do it...

How it works...

There's more...

Learning more about QualitySettings

See also

Implementing slow motion

Getting ready

How to do it...

How it works...

There's more...

Customizing the slider

Adding Motion Blur

Creating sonic ambience

See also

Preventing your game from running on unknown servers

Getting ready

How to do it...

How it works...

There's more...

Improving security by using full URLs in your domain list

Allowing redistribution with more domains

State-driven behavior Do-It-Yourself states

How to do it...

How it works...

See also

State-driven behavior using the State Design pattern

Getting ready

How to do it...

How it works...

Reducing the number of objects by destroying objects at death a time

How to do it...

How it works...

See also

Reducing the number of enabled objects by disabling objects whenever possible

Getting ready

How to do it...

How it works...

There's more...

Note – viewable in Scene panel still counts as visible!

Another common case – only enable after OnTrigger()

See also

Reducing the number of active objects by making objects inactive whenever possible

How to do it...

How it works...

See also

Improving efficiency with delegates and events and avoiding SendMessage!

How to do it...

How it works...

See also

Executing methods regularly but independent of frame rate with coroutines

How to do it...

How it works...

There's more...

Have different actions happening at different intervals

See also

Spreading long computations over several frames with coroutines

How to do it...

How it works...

There's more...

Retrieving the complete Unity log text files from your system

See also

Evaluating performance by measuring max and min frame rates (FPS)

Getting ready

How to do it...

How it works...

There's more...

Turn off runtime display to reduce FPS processing

See also

Identifying performance bottlenecks with the Unity performance Profiler

How to do it...

How it works...

See also

Identifying performance "bottlenecks" with Do-It-Yourself performance profiling

Getting ready

How to do it...

How it works...

See also

Cache GameObject and component references to avoid expensive lookups

Getting ready

How to do it...

Method 1 – AverageDistance calculation

Method 2 – Cache array of Respawn object transforms

Method 3 – Cache reference to Player transform

Method 4 – Cache Player's Vector3 position

Method 5 – Cache reference to SimpleMath component

Method 6 – Cache array of sphere Vector3 positions

How it works...

See also

Improving performance with LOD groups

Getting ready

How to do it...

How it works...

There's more...

Adding more LOD renderers

Fading LOD transitions

See also

Improving performance through reduced draw calls by designing for draw call batching

How to do it...

Static batching

Dynamic batching

There's more...

Reduce the need for textures by vertex painting

Information sources about reducing textures and materials

See also

Conclusion

There's more...

Game audio optimization

Physics engine optimization

More tips for improving script efficiency

Sources of more wisdom about optimization

Published articles that discuss premature optimization

Sources of more about Game Managers and the State Pattern

12. Editor Extensions

Introduction

An editor extension to allow pickup type (and parameters) to be changed at design time via a custom Inspector UI

Getting ready

How to do it...

How it works...

There's more...

Offer the custom editing of pickup parameters via Inspector

Offer a drop-down list of tags for key-pickup to fit via Inspector

Logic to open doors with keys based on fitsLockTag

The need to add [SerializeField] for private properties

Learn more from the Unity documentation

An editor extension to add 100 randomly located copies of a prefab with one menu click

Getting ready

How to do it...

How it works...

There's more...

Child each new GameObject to a single parent, to avoid filling up the Hierarchy with 100s of new objects

A progress bar to display proportion completed of Editor extension processing

Getting ready

How to do it...

How it works...

An editor extension to have an object-creator GameObject, with buttons to instantiate different pickups at cross-hair object location in scene

Getting ready

How to do it...

How it works...

Conclusion

Index

累计评论(0条) 1个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部