This document is about: PUN 1
SWITCH TO

PUN Classic (v1), PUN 2 and Bolt are in maintenance mode. PUN 2 will support Unity 2019 to 2022, but no new features will be added. Of course all your PUN & Bolt projects will continue to work and run with the known performance in the future. For any upcoming or new projects: please switch to Photon Fusion or Quantum.

Photon Stats Gui

The PhotonStatsGui is a simple GUI component to show tracked network metrics at runtime. It is available from the PUN and PUN+ packages inside UtilityScripts folder.

Usage

Just add the PhotonStatsGui component to any active GameObject in the hierarchy. At runtime, a window shows the message count.

Make sure the "Traffic Stats On" checkbox in the inspector is checked. It controls if traffic stats are collected at all. The "stats on" toggle in the GUI is the same value.

A few toggles let you configure the window:

  • buttons: Show buttons for "stats on", "reset stats" and "to log"
  • traffic: Show lower level network traffic (bytes per direction)
  • health: Show timing of sending, dispatches and their longest gaps

Message Statistics

The top most values shows are counter for "messages". Any operation, response and event is counted. Shown are the total outgoing, incoming and sum of those messages as well as an average for the timespan that is tracked. Incoming messages will multiply with players per room. If each individual client is sending a lot, the message count quickly goes up.

Traffic Statistics

These are the byte and packet counters. Anything that leaves or arrives via network is counted here. Even if there are few messages, they could be huge by accident and still cause less powerful clients to drop connection. You also see that there are packages sent when you don't send messages. They keeps the connection alive.

Health Statistics

The block beginning with "longest delta between" is about the performance of your client. We measure how much time passed between consecutive calls of send and dispatch. They should be called ten times per second. If these values ever go beyond one second, check why Update calls are delayed. While you load assets PhotonNetwork.isMessageQueueRunning should be turned off (false).

Button "Stats On" (Enabling Traffic Stats)

The Photon library can track various network statistics but usually this feature is turned off. The PhotonStatsGui will enable the tracking and show those values.

Button "Reset"

This resets the stats but keeps tracking them. This is useful to track message counts for different situations.

Button "To Log"

Pressing this simply logs the current stat values. This can be useful to have a overview how things evolved or just as reference.

Back to top