How to start using the profiler in Unity
It is almost impossible find out what is affecting performance in your game without using a profiler. Luckily Unity comes with one built in. Let’s go over the basics of how to use it.
You find the profiler under Window->Analysis. Open the window and dock it:
By default the profiler is set to Timeline and have Deep Profile disabled. Change Timeline to Hierarchy and enable Deep Profile:
When you click on Play the profiler starts recording the performance of each frame. If you click on a frame on the profile graph the game will automatically pause and you can start to analyse that frame. You can easily analyse any other recorded frame by flicking on another part of the graph:
You can enable or disable the specific type you want to analyse by clicking on the type:
To make it easier to spot issues in the frame, sort by either Total %, GC alloc or Time ms:
To find out what specific part is causing the issue click on the arrow to expand until you get to final part. In this example you can see that there is an issue with the update function in the Inventory script: