Using the Profiler window

Unity has a native tool that helps us to examine how our game performs. This is a Profiler tool and is accessible via the Window | Profiler top menu option. As you can see in the following illustration, there are 13 components available in the Profiler window:

Profiler Components

The individual Profiler names provide a clear indication of what performance measure is being analyzed. In order to fully explore the Profiler window, let's get it up and running with the following steps:

  1. Open your Unity game project. Alternatively, you can download the Starting-Chapter-13 Unity project available from the publisher's companion site.
  2. Using the top menu, select Window | Profiler. Depending on your system, this can open the Profiler in a new window or as a tab. 
  3. In the Profiler window or tab, use the Add Profiler button to add any Profilers not loaded by default. The Profilers that are already loaded will appear in gray and the unloaded Profilers will appear in black.
  4. Put your game in game mode.
  5. Scroll through the Profilers and, using the x in the top-right corner of the Profiler box, close the Profilers that provide little or no data on your game. For example, the Network Operations and Network Messages Profilers are not applicable to the Cucumber Man game. You might leave the following Profilers in your Profiler window:
    • CPU Usage
    • GPU Usage
    • Rendering
    • Memory
    • Audio
    • Physics
    • UI
    • Global Illumination
  6. Let your game run for at least a minute or more, then exit the game. It does not matter whether you play the game while it is running or just sit back and watch the cucumber beetles search for and eat cucumbers. You will have the Profiler data available to you even after the game stops.

We can examine each Profiler to help determine how our game is performing and identify any performance problems. Let's look at the GPU Usage Profiler by clicking on it in the Profiler window. When we select a Profiler, detailed information is provided in the bottom section of the Profiler window. 

By reviewing the detailed information provided, such as the GPU Usage information shown here, we can determine component-level performance. In the following example, we can see that our Camera.Renderer takes the greatest draw on the GPU. We can also drill down to greater fidelity by clicking the gray triangles to the left of each component:

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

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