Book Image

Unity 5 for Android Essentials

By : Valera Cogut
Book Image

Unity 5 for Android Essentials

By: Valera Cogut

Overview of this book

Table of Contents (14 chapters)
Unity 5 for Android Essentials
About the Author
About the Reviewers

The scriptable profiler tool

The fact that developers can use the Unity profiler for profiling their own code or certain pieces of code is very important. In order to display statistics information about some of your function or for some part of your code in the Unity profiler, you just need to include your code between two calls, Profiler.BeginSample and Profiler.EndSample. After that you can use the visual Unity profiler tool to search for bottlenecks and spikes in your code.


The profiler is only available in Unity Pro. In standalone games, the profiler can dump all profiling information using Profiler.log and Profiler.enabled.

To create your own tool, you can utilize the following Unity API calls:

  • FindObjectsOfTypeAll

  • FindObjectsOfType

  • GetRuntimeMemorySize

  • GetMonoHeapSize

  • GetMonoUsedSize

  • Profiler.BeginSample

  • Profiler.EndSample

  • UnloadUnusedAssets

  • System.GC.GetTotalMemory

  • Profiler.usedHeapSize

Unity profiler tricks

There is the capability to export the profiling information to...