The Unity Profiler is a profiling tool available in Unity. For memory usage optimizations, look at the Unity Profiler first. It helps you identify issues related to CPU usage, GPU usage, rendering, memory, audio, physics, etc. The Unity Profiler can be attached to the game while its running in the editor or standalone. Here you only spend time looking at the Unity Profiler inside Unity.
- [Instructor] Inside the exercise files folder for this video, click on the UnityGame_Unoptimized folder and navigate to the Unity project directory. Once there, right click on the factory escape executable and create shortcut. We create a desktop shortcut so we can quickly start it before we start collecting data. Once the desktop shortcut is created, let's double click on the WPRUI shortcut to start it up. Click yes on any prompts that come up.
Let's then click on the more options drop down arrow, and let's uncheck this first level triage box. And let's make sure every box is unchecked under the resource analysis section and the scenario analysis section. Now let's have the Windows performance recorder record CPU usage for us, which will let us see the functions the game is calling and how it presents frames. Next let's select virtual lock usage.
This will show us the game's memory usage, which might be high due to multi sample anti alias modes being used. Now there are many other options we could check, but you want to be mindful of how many you select since each one adds overhead to the overall collection process. This can result in dropped packets that will have the Windows performance analyzer showing us inaccurate information. So we want to be mindful of that and only focus on two areas that are common for bottlenecks and game performance. With all of the options selected I'm going to double click on the game.
And I'm going to set the screen resolution to the max and I'm going to keep the graphics quality set to fantastic. I'm also going to keep it in full screen mode, and then hit play. Let's now alt tab back to the Windows performance recorder menu, and this is where we want to pull out a stopwatch. Since we won't be able to keep track of the time elapsed on the Windows performance recorder menu, we want to pull out our phone and use the stopwatch and keep track of time. What we're going to do is hit start and then we're going to alt tab back to the game.
We're going to wait for 15 seconds without pressing any buttons, so we can see the system resource utilization in idle mode, then after 15 seconds, we're going to move around a bit and then wait for 10 seconds before finally hitting save. Okay, with that said, put the stopwatch ready, let's hit start, and then alt tab back to the game. Let's wait for 15 seconds.
And then let's move over to this crane right over here. And then let's stop for 10 seconds. Let's then alt tab back to the WPRUI menu and hit save. For the comment let's put wpt unity, and then hit save. Once it's done saving let's hit the open folder button, where we are taken to where the trace file was generated and this NGENPDB folder, which contains the associated symbols which will let us see Windows function names.
Let's rename these to something more meaningful, like WPTUnity. And let's rename the Symbols folder to WPTUnity.etl.NGENPDB. And that's it. We have collected data that we can now analyze inside the Windows performance analyzer. These files will be included in the exercise files for those of you who have access.