Mini Profiler Documentation

Components

Mini Profiler

In order to create a panel to watch a variable, you need two components. The first is the Mini Profiler main component or just Mini Profiler and the second one is any Value Provider.

The Mini Profiler component is responsible for the drawing. The Pro version is very configurable but the Standard have the enough funcionality to work properly.

  • Read Interval: This configures the interval between reads. Some variables need to be read every frame, some every second, some every minute, etc.

    Note that in the Pro version you must configure this to higher values if the custom variable you’re watching is slow to calculate and is causing performance issues.

  • Visible: Configures if the panel is expanded (visible) or collapsed. A collapsed panel contains only the last read information (minimum, average and maximum values) and the title. This is very useful when you have a panel above something important of your game screen but you don’t want to entirely get rid of it.
  • Touch Toggle Visible: Whether or not you want the panel to be collapsed/expanded on touch/click. This is very useful on touch devices. This works together with Visible property.
  • Keep Reading: Whether the collapsed panel should keep reading the variable. If you want the panel to continue to read and show the reading results even when it’s collapsed you can turn this variable on. This works together with Visible property.
  • Shortcut: You can configure a keyboard shortcut to collapse/expand the panel. This is particulary useful when your game hides the mouse cursor. This works together with Visible property.

    Pro tip 1: Configure the same keyboard shortcut for all panels to show/collapse them all at once.

    Pro tip 2: Configure the shortcut to Escape key to make the Back Button of mobile devices toggle panels visibility.

  • Colors: In the Pro version you can configure the colors of your panel.

    • Background Color: Color that paints the entire background of the graphic and the bottom line.
    • Average Value Color: Color that paints the average line and average value label in the bottom line.
    • Max Value Color: Color that paints the maximum value read label in the bottom line and is merged with Min Color depending on the value in the graphic.
    • Min Color: Color that paints the minimum value read label in the bottom line and is merged with Max Color depending on the value in the graphic.
    • Title Color: Color that paints the title label in the bottom line.

    Note that in Pro version you don’t need to configure all the colors individually. The package comes with several color themes that you just drop into the Mini Profiler Component and set all the color at once.

You can change the Scale and Position of a Mini Profiler panel changing it’s transform Scale and Position values.

Value Provider

Value Provider is the base class to components that (you guessed it) provides the values to Mini Profiler.

  • Title: Panel title.
  • Number Format: How the numbers should be formatted to be human readable. Check the official C# documentation for more information about numeric formatiing: Custom Numeric Format Strings

Framerate Value Provider

As part of the basic package (and consequently the Pro package) the plugin have a Framerate Value Provider, a ready-to-use component that watches the game frame rate (FPS) over time.

Note that this is a basic implementation. If you need something more precise, you can extend it (in Pro version) and make it as powerful as you need.

All the packages comes with a Framerate Wather Prefab in the folder Mini Profiler/Prefabs that let’s you just drag it to the scene and start to watch the framerate right away.

Memory Value Provider

As part of the basic package (and consequently the Pro package) the plugin have a Memory Value Provider, a ready-to-use component that watches the game memory usage over time.

Note that this is a basic implementation. If you need something more precise, you can extend it (in Pro version) and make it as powerful as you need.

All the packages comes with a Memory Wather Prefab in the folder Mini Profiler/Prefabs that let’s you just drag it to the scene and start to watch the memory usage right away.

Mini Profiler Container

If you need to organize several panels dynamically, their position, scale, alignment, it is hard to make them work without unnecessary spaces or overlaps. That’s when Mini Profiler Container comes to action.

Use the Mini Profiler Container component when you need more than one panel in the scene and need to organize them automatically aligning them to a corner. Just make the panels children of the Mini Profiler Container and it’s all set.

Basically, when you change the scale or Visible property of child Mini Profiler panels, the position of all others are updated.

Note that the panels are organized vertically and if they are larger than the screen, they will be hidden. A solution would be collapse other panels to see the ones that are out of the screen. This behavior could be changed in the future.

  • Margin: Margin between the screen border and panels.
  • Spacing: Vertical spacing between panels.
  • Alignment: Which corner the panels should be aligned to.

Keyboard Shortcut

This is a helper class to set a shortcut to toogle Mini Profilers Visibility.

  • Ctrl: Whether the Control modifier key should be hold for the shortcut.
  • Alt: Whether the Alt modifier key should be hold for the shortcut.
  • Shift: Whether the Shift modifier key should be hold for the shortcut.
  • Key: The main shortcut key.

Pro tip 1: Configure the same keyboard shortcut for all panels to show/collapse them all at once.

Pro tip 2: Configure the shortcut to Escape key to make the Back Button of mobile devices toggle panels visibility.

How to…

Here are some quick tutorials for you to start to use the Mini Profiler in to time.

Add a framerate or memory usage panel

If you need any of these panels, you are lucky. Just go to the Game Object > UI > Mini Profiler menu or right click on your scene to add one of these panels.

Besides, the package you just imported to your Unity project already have a Prefab for each one of these panels at Mini Profiler/Prefabs folder. All you need to do is drag one or more of them anywhere into your scene and you’re done! Now hit play and see the result.

Create a custom panel

If you don’t like the Prefabs that come with the package or want to watch a custom variable you can create your own panels. Easy:

  1. Create a new Game Object anywhere in your scene
  2. Add the Mini Profiler Component
  3. Add the Value Provider Component you want to watch (all versions come with Framerate and Memory Value Providers).

And that’s it! play the scene to see the result.

Watch a custom variable

Custom panels let you watch any numeric variable over time like you do with framerate and memory. It’s very simple. All you need to do is extend the AbstractValueProvider class and implement only one property! Take the framerate as an example:

AbstractValueProvider is a MonoBehaviour which means that now you just need to add it to a GameObject with a Mini Profiler Component and you’re done! Easy, isn’t?

Order panel automatically

The Pro version comes with a special component: Mini Profiler Container, which organizes automatically its Mini Profiler child components when theirs change.

Just create a Game Object anywhere in your scene and add the Mini Profiler Container component to it. Now, all you need to do is create a custom panel or use one of the available Prefabs and add them to the scene as children of the Container panel.

Now your panels are aligned automatically and if you change the scale or the visibility of one of them, all the others will be positioned automatically for you.

If you want to create panels in more than one corner, create a Mini Profiler Container for each corner.

Position and scale panels

You can position and scale your panels using the Transform’s Position and Scale properties.

Set a shortcut to toggle panels

All you need to do is set the property Shortcut of a Mini Profiler component.

Apply a theme

The Pro version lets you change the colors of your panels right in the editor. If you are lazy like me, you can drop one of the color themes into a Mini Profiler component and all colors will be set for you. The package comes with several color themes in the folder Mini Profiler/Editor. Color themes are Unity’s Color Preset Libraries and can be used in other places of your project.

Create a panel by code

You can either instantiate one of the given prefabs or you can create a new
panel like this:

Note that the order is important since the Mini Profiler Component depends on a Value Provider to work properly.