
Unity Game Optimization
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
- Explore techniques for solving performance issues with your VR projects
- Learn best practices for project organization to save time through an improved workflow
Book DescriptionUnity engine comes with a great set of features to help you build high-performance games. This Unity book is your guide to optimizing various aspects of your game development, from game characters and scripts, right through to animations. You'll explore techniques for writing better game scripts and learn how to optimize a game using Unity technologies such as ECS and the Burst compiler. The book will also help you manage third-party tooling used with the Unity ecosystem. You'll also focus on the problems in the performance of large games and virtual reality (VR) projects in Unity, gaining insights into detecting performance issues and performing root cause analysis. As you progress, you'll discover best practices for your Unity C# script code and get to grips with usage patterns. Later, you'll be able to optimize audio resources and texture files, along with effectively storing and using resource files. You'll then delve into the Rendering Pipeline and learn how to identify performance problems in the pipeline. In addition to this, you'll learn how to optimize the memory and processing unit of Unity. Finally, you'll cover tips and tricks used by Unity professionals to improve the project workflow. By the end of this book, you'll have developed the skills you need to build interactive games using Unity and its components.What you will learn - Apply the Unity Profiler to find bottlenecks in your app, and discover how to resolve them
- Discover performance problems that are critical for VR projects and learn how to tackle them
- Enhance shaders in an accessible way, optimizing them with subtle yet effective performance tweaks
- Use the physics engine to keep scenes as dynamic as possible
- Organize, filter, and compress art assets to maximize performance while maintaining high quality
- Use the Mono framework and C# to implement low-level enhancements that maximize memory usage and prevent garbage collection
Who this book is forThe book is intended for intermediate Unity game developers who wants to maximize the performance of their game. The book assumes familiarity with C# programming.
More details
Other editions
Additional editions

Content
- Cover
- Title Page
- Copyright and Credits
- Dedication
- About Packt
- Contributors
- Table of Contents
- Preface
- Section 1: Base Scripting Optimization
- Chapter 1: Evaluating Performance Problems
- Gathering profiling data using the Unity Profiler
- Launching the Profiler
- Editor or standalone instances
- Connecting to a WebGL instance
- Remote connection to an iOS device
- Remote connection to an Android device
- Editor profiling
- The Profiler window
- Profiler controls
- Add Profiler
- Playmode
- Record
- Deep Profile
- Allocation Callstack
- Clear
- Load
- Save
- Frame Selection
- Timeline View
- Breakdown View Controls
- Breakdown View
- The CPU Usage area
- The GPU Usage area
- The Rendering area
- The Memory area
- The Audio area
- The Physics 3D and Physics 2D areas
- The network messages and network operations areas
- The Video area
- The UI and UI Details areas
- The Global Illumination area
- Best approaches to performance analysis
- Verifying script presence
- Verifying script count
- Verifying the order of events
- Minimizing ongoing code changes
- Minimizing internal distractions
- Minimizing external distractions
- Targeted profiling of code segments
- Profiler script control
- Custom CPU profiling
- Final thoughts on profiling and analysis
- Understanding the Profiler
- Reducing noise
- Focusing on the issue
- Summary
- Chapter 2: Scripting Strategies
- Obtaining components using the fastest method
- Removing empty callback definitions
- Caching component references
- Sharing calculation output
- Update, coroutines, and InvokeRepeating
- Faster GameObject null reference checks
- Avoid retrieving string properties from GameObjects
- Using appropriate data structures
- Avoiding re-parenting transforms at runtime
- Considering caching transform changes
- Avoiding Find() and SendMessage() at runtime
- Assigning references to pre-existing objects
- Static classes
- Singleton components
- A global messaging system
- A globally accessible object
- Registration
- Message processing
- Implementing the messaging system
- Message queuing and processing
- Implementing custom messages
- Message sending
- Message registration
- Message cleanup
- Wrapping up the messaging system
- Disabling unused scripts and objects
- Disabling objects by visibility
- Disabling objects by distance
- Using distance-squared over distance
- Minimizing deserialization behavior
- Reducing serialized object size
- Loading serialized objects asynchronously
- Keeping previously loaded serialized objects in memory
- Moving common data into ScriptableObjects
- Loading scenes additively and asynchronously
- Creating a custom Update() layer
- Summary
- Section 2: Graphical Optimizations
- Chapter 3: The Benefits of Batching
- Draw calls
- Materials and shaders
- The Frame Debugger
- Dynamic batching
- Vertex attributes
- Mesh scaling
- Dynamic batching summary
- Static batching
- The Static flag
- Memory requirements
- Material references
- Static batching caveats
- Edit Mode debugging of static batching
- Instantiating static meshes at runtime
- Static batching summary
- Summary
- Chapter 4: Optimizing Your Art Assets
- Audio
- Importing audio files
- Loading audio files
- Encoding formats and quality levels
- Audio performance enhancements
- Minimizing active audio source count
- Enabling Force to Mono for 3D sounds
- Resampling to lower frequencies
- Considering all compression formats
- Being cautious of streaming
- Applying filter effects through mixer groups to reduce duplication
- Using remote content streaming responsibly
- Consider using audio module files for background music
- Texture files
- Texture compression formats
- Texture performance enhancements
- Reducing texture file size
- Using mipmaps wisely
- Managing resolution downscaling externally
- Adjusting anisotropic filtering levels
- Consider atlasing
- Adjusting compression rates for nonsquare textures
- Sparse textures
- Procedural materials
- Asynchronous texture uploading
- Mesh and animation files
- Reducing the polygon count
- Tweaking mesh compression
- Using Read-Write Enabled appropriately
- Considering baked animations
- Combining meshes
- Asset bundles and resources
- Summary
- Chapter 5: Faster Physics
- Understanding the physics engine
- Physics and time
- Maximum Allowed Timestep
- Physics updates and runtime changes
- Static colliders and dynamic colliders
- Collision detection
- Collider types
- The Collision Matrix
- Rigidbody active and sleeping states
- Ray and object casting
- Debugging physics
- Physics performance optimizations
- Scene setup
- Scaling
- Positioning
- Mass
- Using static colliders appropriately
- Using trigger volumes responsibly
- Optimizing the Collision Matrix
- Preferring discrete collision detection
- Modifying the fixed update frequency
- Adjusting the Maximum Allowed Timestep
- Minimizing raycasting and bounding-volume checks
- Avoiding complex Mesh Colliders
- Using simpler primitives
- Using simpler Mesh Colliders
- Avoiding complex physics components
- Letting physics objects sleep
- Modifying the solver iteration count
- Optimizing ragdolls
- Reducing joints and colliders
- Avoiding inter-ragdoll collisions
- Replacing, deactivating, or removing inactive ragdolls
- Knowing when to use physics
- Summary
- Chapter 6: Dynamic Graphics
- Exploring the Rendering Pipeline
- The GPU frontend
- The GPU backend
- Fill Rate
- Overdraw
- Memory bandwidth
- Lighting and shadowing
- Forward Rendering
- Deferred Shading
- Vertex-Lit shading (legacy)
- Global Illumination
- Multithreaded Rendering
- Low-level rendering APIs
- Detecting performance issues
- Profiling rendering issues
- Brute force testing
- Rendering performance enhancements
- Enabling/disabling GPU skinning
- Reducing geometric complexity
- Reducing tessellation
- Employing GPU instancing
- Using mesh-based LOD
- Culling groups
- Making use of Occlusion Culling
- Optimizing Particle Systems
- Making use of Particle System culling
- Avoiding recursive Particle System calls
- Optimizing Unity UI
- Using more Canvases
- Separating objects between static and dynamic Canvases
- Disabling Raycast Target for non-interactive elements
- Hiding UI elements by disabling the parent Canvas component
- Avoiding Animator components
- Explicitly defining the event camera for World Space Canvases
- Don't use alpha to hide UI elements
- Optimizing ScrollRects
- Make sure to use a RectMask2D
- Disable Pixel Perfect for ScrollRects
- Manually stop ScrollRect motion
- Using empty UIText elements for full-screen interaction
- Checking the Unity UI source code
- Checking the documentation
- Shader optimization
- Consider using shaders intended for mobile platforms
- Using small data types
- Avoiding changing precision while swizzling
- Using GPU-optimized helper functions
- Disabling unnecessary features
- Removing unnecessary input data
- Exposing only necessary variables
- Reducing mathematical complexity
- Reducing texture sampling
- Avoiding conditional statements
- Reducing data dependencies
- Surface Shaders
- Use shader-based LOD
- Using less texture data
- Testing different GPU texture compression formats
- Minimizing texture swapping
- VRAM limits
- Preloading textures with hidden GameObjects
- Avoid texture thrashing
- Lighting optimization
- Using real-time shadows responsibly
- Using culling masks
- Using baked lightmaps
- Optimizing rendering performance for mobile devices
- Avoiding alpha testing
- Minimizing draw calls
- Minimizing Material count
- Minimizing texture size
- Making textures square and the power-of-two
- Using the lowest possible precision formats in shaders
- Summary
- Section 3: Advance Optimizations
- Chapter 7: Optimizations for Virtual and Augmented Reality
- Overview of XR technology
- Developing XR products
- User comfort
- Performance enhancements in XR
- The kitchen sink
- Single Pass versus Multi Pass Stereo rendering
- Applying antialiasing
- Using forward rendering
- Applying image effects in VR
- Backface culling
- Spatialized audio
- Avoiding camera physics collisions
- Avoiding Euler angles
- Exercise restraint
- Keeping up to date with the latest developments
- Summary
- Chapter 8: Masterful Memory Management
- The Mono platform
- Memory domains
- The stack
- The heap
- Garbage collection
- Memory fragmentation
- Garbage collection at runtime
- Threaded garbage collection
- Code compilation
- IL2CPP
- Profiling memory
- Profiling memory consumption
- Profiling memory efficiency
- Memory management performance enhancements
- Garbage collection tactics
- Manual JIT compilation
- Value types and reference types
- Pass by value and by reference
- Structs are value types
- Arrays are reference types
- Strings are immutable reference types
- String concatenation
- StringBuilder
- String formatting
- Boxing
- The importance of data layout
- Arrays from the Unity API
- Using InstanceIDs for dictionary keys
- foreach loops
- Coroutines
- Closures
- The .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
- IL2CPP optimizations
- WebGL optimizations
- Summary
- Chapter 9: The Data-Oriented Technology Stack
- The problem of multithreading
- A small example
- The Unity Job System
- A basic job
- A more complex example
- The new ECS
- Mixing ECS and jobs
- The burst compiler
- Summary
- Chapter 10: Tactical Tips and Tricks
- Editor hotkey tips
- Working with GameObjects
- Scene window
- Arrays
- Interface
- In-editor documentation
- Editor UI tips
- Script Execution Order
- Editor files
- The Inspector window
- The Project window
- The Hierarchy window
- The Scene and Game windows
- Playmode
- Scripting tips
- General
- Attributes
- Variable attributes
- Class attributes
- Logging
- Useful links
- Custom Editor scripts and menu tips
- External tips
- Other tips
- Summary
- Other Books You May Enjoy
- Index
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.