Unity Profiler- Game Dev Series 144
Objective: using Unity Profiler to optomizing your game.
Unity Profiler is a build-in game performance checking/debugging function that allows you easily to optimize your works.
In this article, I would introduce the basic usage of this function.
To use Profiler at the first time, you would need to open the window at the drop down menu Windows> Analysis> Profiler, or you can use Ctrl + 7 to open Profiler.
The very top section of Profiler is Profiler Modules, where you can scanning for each part of performance when your game is running.
To get a complete analysis of gameplaying, make sure enable the Deep Profile option.
The most common part to examine the performance is the CPU Usage section.
As you running the game, there will have a analysis graphic running on Profiler. As you can see, it has been sorted from top to bottom by frame rate.
The frame rate gets lower, the peak of chart gets higher.
Then we can pause the game(or simply click on any peak of chart) and select the peak to check what cause the frame rate dropped down.
After selected the peak of losing frame, we can check another section of Profiler.
For the first time of using Profiler, make sure you change the default section Timeline to Hierarchy, where will reveal more detail of game performance on every frame or selected frame.
As the previous part that we selected a peak on CPU Usage, we can check the percent of using CPU.
More than that, there are more data that we can get a quick view from Hierarchy.
There are: times of calling, garbage collection allocation, total time processing microsecond, and self-processing microsecond.
You can always open any drop down menu to get a deep examination.
With Hierarchy, you can easily locate the main issue that causing frame dropping during gameplay.
As you can see, the part of EditorLoop take a huge percent on game performance, which is bacause we run the game in editor.
Profiler on standalone game
We can also use Profiler after we build the game and running it.
To enable this function, first we need to open Build Settings, then click both Developer Build and Autoconnect Profiler.
Then select Build And Run, and wait for your game finished building and running.
While the game is running, you can switch back to Unity Editor, and you should see the Profiler is also running.
Now you can analysis the complete game performance without spending extra resource on editor.