The profiler is a Unity Pro feature. It's a great help when optimizing your game. It can report the amount of time spent for rendering, animating, or code processing.
Open the profiler window by navigating to Window | Profiler. The following window appears (yours will be empty):
Here's an explanation of the most important functions of the Profiler window:
The profiler records each frame's data and displays it as a timeline. You can view this recorded data separately for each frame by clicking anywhere in the timeline (9).
You should try to optimize your code, assets, scenes, and shaders to avoid having high time values. You should also avoid spikes like this one:
The spike in the preceding screenshot means that your frame took longer than the others to render, leading to a frame-rate drop. By clicking on it, you'll retrieve information about which instructions took longer to process. By doing so, you'll gradually track down the different sources of your frame-rate drop.
Currently, the profiler is set up to record information from Unity Editor and not the device. It is possible to record data directly from the device while it's running the build, but we have a slight setup procedure for the very first time.
Connect your Android device to your computer now. First, we'll check whether the device is detected by the Android Debug Bridge (ADB):
cmd
in the new window and hit Enter or click on the Ok button.cd
followed by your Android SDK's platform-tools
folder location and hit Enter. For example, in my case it is:cd C:SDKplatform-tools
adb devices
and hit Enter to display the detected device list. You should have at least one device listed, which should be similar to this:List of devices attached R32D103DCQA device
If your device list is empty, reconnect your device and try again. If it's still not detected, restart your computer. If it doesn't show in the list after a restart, reinstall your device's USB drivers and check your cable; some USB cables can only recharge your device but do not allow data transfers.
Once you have your device displayed in the device list, follow these steps to set up the profiler on the Android device:
.apk
file.Ok. When Unity has finished building and pushing the package to the device, open the profiler by navigating to Window | Profiler.
Now, we must request to display the connected device's profiler data:
And that's it! You can now analyze the data fetched from the connected device. You can see that the GPU Usage category in the profiler is empty; this is simply because GPU profiling isn't supported on mobile devices.
You can now enable Wi-Fi profiling by following the instructions at http://docs.unity3d.com/Manual/Profiler.html.
3.14.251.128