Preface

User experience is a critical component of any game. User experience includes not only our game's story and its gameplay, but also how smoothly the graphics run, how reliably it connects to multiplayer servers, how responsive it is to user input, and even how large the final application file size is due to the prevalence of app stores and cloud downloads. The barrier to entering game development has been lowered considerably thanks to the release of cheap, AAA-industry-level game development tools such as Unity. However, the features and quality of the final product that our players expect us to provide is increasing with every passing day. We should expect that every facet of our game can and will be scrutinized by players and critics alike.

The goals of performance optimization are deeply entwined with user experience. Poorly optimized games can result in low frame rates, freezes, crashes, input lag, long loading times, inconsistent and jittery runtime behavior, physics engine breakdowns, and even excessively high battery power consumption (particularly important in this era of mobile devices). Having just one of these issues can be a game developer's worst nightmare as reviews will tend to focus on the one thing that we did badly, in spite of all the things that we did well.

Performance is all about making the best use of the available resources, which includes the CPU resources such as CPU cycles and main memory space, Graphics Processing Unit (GPU) resources such as memory space (VRAM) and memory bandwidth, and so on. But optimization also means making sure that no single resource causes a bottleneck at an inappropriate time, and that the highest priority tasks get taken care of first. Even small, intermittent hiccups and sluggishness in performance can pull the player out of the experience, breaking immersion and limiting our potential to create the experience we intended.

It is also important to decide when to take a step back and stop making performance enhancements. In a world with infinite time and resources, there would always be another way to make it better, faster, or easier to maintain. There must be a point during development where we decide that the product has reached acceptable levels of quality. If not, we risk dooming ourselves to implementing further changes that result in little or no tangible benefit.

The best way to decide if a performance issue is worth fixing is to answer the question "will the user notice it?". If the answer to this questions is "no", then performance optimization would be a wasted effort. There is an old saying in software development:

Premature optimization is the root of all evil

Premature optimization is the cardinal sin of reworking and refactoring code to enhance performance without any proof that it is necessary. This could mean either making changes without showing that a performance problem even exists (answering the question of whether or not it would be noticeable to the user), or making changes because we only believe a performance issue might stem from a particular area before it has been proven to be true. Making these mistakes has cost software developers, as a collective whole, a depressing number of work hours for nothing.

This book intends to give us the tools, knowledge, and skills we need to both detect and fix performance issues in our application, no matter where they stem from. This could be hardware components such as the CPU, GPU, or RAM, within software subsystems such as Physics, Rendering, or within the Unity Engine itself. In addition, the more resources we save, the more we can do within the Unity Engine with the same hardware system, allowing us to generate more interesting and dynamic gameplay.

This will give our game a better chance of succeeding and standing out from the crowd in a marketplace that is inundated with new, high quality games every single day.

What this book covers

Chapter 1, Detecting Performance Issues, provides an exploration of the Unity Profiler and a series of methods to profile our application, detect performance bottlenecks, and perform root cause analysis.

Chapter 2, Scripting Strategies, deals with the best practices for our Unity C# Script code, minimizing Component overhead, improving inter-object communication, and more.

Chapter 3, The Benefits of Batching, explores Unity's Dynamic and Static Batching systems to ease the burden on the rendering system.

Chapter 4, Kickstart Your Art, helps you understand the underlying technology behind our art assets and learn how to avoid common pitfalls with importing, compression, and encoding.

Chapter 5, Faster Physics, is about investigating the nuances of Unity's physics system for both 3D and 2D games, and how to properly organize our physics objects for improved performance.

Chapter 6, Dynamic Graphics, provides an in-depth exploration of the rendering system, and how to improve applications that suffer rendering bottlenecks in the GPU, or CPU, and specialized techniques for mobile devices.

Chapter 7, Masterful Memory Management, examines the inner workings of the Unity Engine, the Mono Framework, and how memory is managed within these components to protect our application from heap allocations and runtime garbage collection.

Chapter 8, Tactical Tips and Tricks, deals with a multitude of useful techniques used by professionals to improve project workflow and scene management.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.72.15