售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Unity 5 Game Optimization
Table of Contents
Unity 5 Game Optimization
Credits
About the Author
Acknowledgments
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
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Detecting Performance Issues
The Unity Profiler
Launching the Profiler
Editor or standalone instances
Editor profiling
The Unity Webplayer connection
Remote connection to an iOS device
Remote connection to an Android device
The Profiler window
Controls
CPU Area
The GPU Area
The Rendering Area
The Memory Area
The Audio Area
The Physics 3D/2D Area
Best approaches to performance analysis
Verifying script presence
Verifying script count
Minimizing ongoing code changes
Minimizing internal distractions
Minimizing external distractions
Targeted profiling of code segments
Profiler script control
Custom CPU Profiling
Saving and loading Profiler data
Saving Profiler data
Loading Profiler data
Final thoughts on Profiling and Analysis
Understanding the Profiler
Reducing noise
Focusing on the issue
Summary
2. Scripting Strategies
Cache Component references
Obtaining Components using the fastest method
Removing empty callback declarations
Avoiding the Find() and SendMessage() methods at runtime
Static classes
Singleton Components
Assigning references to pre-existing objects
A global messaging system
A globally accessible object
Registration
Message processing
Implementing the messaging system
Message queuing and processing
Implementing a custom message
Message registration
Message sending
Message cleanup
Wrapping up the messaging system
Disabling unused scripts and objects
Disabling objects by visibility
Disabling objects by distance
Consider using distance-squared over distance
Avoid retrieving string properties from GameObjects
Update, Coroutines, and InvokeRepeating
Consider caching Transform changes
Faster GameObject null reference checks
Summary
3. The Benefits of Batching
Draw Calls
Materials and Shaders
Dynamic Batching
Vertex attributes
Uniform scaling
Dynamic Batching summary
Static Batching
The Static flag
Memory requirements
Material references
Static Batching caveats
Edit Mode debugging of Static Batching
Avoiding instantiating static meshes at runtime
Visibility and rendering
Static Batching summary
Summary
4. Kickstart Your Art
Audio
Loading audio files
Profiling audio
Additional loading options
Encoding formats and quality levels
Audio performance enhancements
Minimize active Audio Source count
Minimize Audio Clip references
Enable Force to Mono for 3D sounds
Resample to lower frequencies
Consider all encoding formats
Beware of streaming
Apply Filter effects through Mixer groups to reduce duplication
Use "WWW.audioClip" responsibly
Consider Audio Module files for background music
Texture files
Compression formats
Texture performance enhancements
Reduce Texture file size
Use Mip Maps wisely
Manage resolution downscaling externally
Adjust Anisotropic Filtering levels
Consider Atlasing
Adjust compression rates for non-square Textures
Sparse Textures
Procedural Materials
Mesh and animation files
Reducing polygon count
Tweaking Mesh Compression
Use Read-Write Enabled appropriately
Import/calculate only what's needed
Consider baked animations
Let Unity optimize meshes
Combine meshes
Summary
5. Faster Physics
Physics Engine internals
Physics and time
The Fixed Update loop
Maximum Allowed Timestep
Physics updates and runtime changes
Static and Dynamic Colliders
Collision detection
Collider types
The Collision Matrix
Rigidbody active and sleeping states
Ray and object casting
Physics performance optimizations
Scene setup
Scaling
Positioning
Mass
Use Static Colliders appropriately
Optimize the Collision Matrix
Prefer discrete collision detection
Modify the FixedUpdate frequency
Adjust the Maximum Allowed Timestep
Minimize cast and bounding-volume checks
Avoid complex Mesh Colliders
Use simpler primitives
Use simpler Mesh Colliders
Avoid complex physics components
Let physics objects sleep
Modify Solver Iteration Count
Optimizing ragdolls
Reduce Joints and Colliders
Avoid inter-ragdoll collisions
Disable or remove inactive ragdolls
Know when to use physics
Consider upgrading to Unity 5
Summary
6. Dynamic Graphics
Profiling rendering issues
GPU profiling
The Frame Debugger
Brute force testing
CPU-bound
Multithreaded rendering
GPU Skinning
Front end bottlenecks
Level Of Detail
Disable GPU Skinning
Reduce tessellation
Back end bottlenecks
Fill rate
Overdraw
Occlusion Culling
Shader optimization
Consider using Shaders intended for mobile platforms
Use small data types
Avoid changing precision while swizzling
Use GPU-optimized helper functions
Disable unnecessary features
Remove unnecessary input data
Only expose necessary variables
Reduce mathematical complexity
Reduce texture lookups
Avoid conditional statements
Reduce data dependencies
Surface Shaders
Use Shader-based LOD
Memory bandwidth
Use less texture data
Test different GPU Texture Compression formats
Minimize texture sampling
Organize assets to reduce texture swaps
VRAM limits
Texture preloading
Texture thrashing
Lighting and Shadowing
Forward Rendering
Deferred Shading
Vertex Lit Shading (legacy)
Real-time Shadows
Lighting optimization
Use the appropriate Shading Mode
Use Culling Masks
Use Baked Lightmaps
Optimize Shadows
Optimizing graphics for mobile
Minimize Draw Calls
Minimize the Material count
Minimize texture size and Material count
Make textures square and power of 2
Use the lowest possible precision formats in Shaders
Avoid Alpha Testing
Summary
7. Masterful Memory Management
The Mono platform
The compilation process
Manual JIT compilation
Memory usage optimization
Unity memory domains
Native memory
Managed memory
Garbage collection
Memory fragmentation
Garbage collection at runtime
Threaded garbage collection
Garbage collection tactics
Value types and Reference types
Pass by value and pass by reference
Structs are Value types
Arrays are Reference types
Strings are immutable Reference types
String concatenation
Boxing
The importance of data layout
The Unity API
The foreach loops
Coroutines
Closures
.NET library functions
Temporary work buffers
Object pooling
Prefab pooling
Poolable Components
The Prefab pooling system
Prefab pools
Object spawning
Instance prespawning
Object despawning
Prefab pool testing
Prefab pooling and Scene loading
Prefab pooling summary
The future of Mono and Unity
Summary
8. Tactical Tips and Tricks
Editor hotkey tips
GameObjects
Scene View
Arrays
Interface
Other
Editor interface tips
General
The Inspector View
The Project View
The Hierarchy View
The Scene and Game Views
Play Mode
Scripting tips
General
Attributes
Variable attributes
Class attributes
Logging
Useful links
Custom editors/menus tips
External tips
Other tips
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜