Fusion Statistics
Overview
Fusion Statistics consists of a set of UI components for monitoring useful Fusion telemetry. The FusionStatistics
component is the primary component for generating, initializing and controlling a hierarchy of telemetry UI elements.
Fusion Statistics uses the basic UnityEngine.UI
components, which allows stats to be viewed in builds as either a screen overlay or attached to an object in 3D space.
Basic Usage
To get started with the Fusion Statistics:
- Add the component
FusionStatistics
on aNetworkRunner
object before it was started; or, - Add the
FusionStatistics
on theNetworkRunner
after initialization and hit the Setup Statistics Panel button on the editor (it is also possible to call a method with the same name from code).
After the initialization of the NetworkRunner
(or a manual setup using the editor button) a canvas root is instantiated with space for the desired statistics charts to be analyzed.
If any stats are selected in the editor dropdown, a chart tracking them will be added automatically, but it is possible to toggle the stats in the dropdown located in the upper left area of the statistics panel.
Note: The FusionStatistics
component must be on the same game object as the NetworkRunner
, as it will connect to it and collect all the requested stats data.
Statistics Panel Buttons and Usability
Click and drag any of the panel's top or bottom bars, or any static area such as the background, to move the statistics panel around the screen.
If the panel is dropped outside the visible screen area, it will snap back to its original position.
- Hide/collapse the body of the statistics panel, leaving only the top header. While it is collapsed, no statistics data is collected and the charts are cleaned up.
- Dropdown list to toggle visible statistics charts on the panel. Select an already added stat to remove it.
- A label which displays the
PlayerRef
of the connectedNetworkRunner
local player. Useful for differentiating statistics panels when using multi-peer. - Button to destroy the statistics panel. The
FusionStatistics
component is still alive on the `NetworkRunner' object, calling the Setup Statistics Panel method or pressing the editor button again will restore it. - Open a configuration panel to use the world anchor settings.
- Restore the statistics panel to its original position.
Statistic Graph
The image above shows how each stat is displayed on the panel, the graph has some useful information such as a peak value (from values within the buffer), the average value and the last value collected.
Individual stat graph can be collapsed by using the arrow button.
Thresholds
It is possible to see that the chart bar changes colors depending on the value and some labels on the left side. These are the thresholds of the stat, each stat can have 3 custom thresholds that can be defined from code with FusionStatistics.SetStatsCustomConfig()
method or from the FusionStatistics
component editor, just add a new rule for each stat of choice.
- Values bellow threshold 1 are green.
- Values in between threshold 1 and threshold 2 are yellow.
- Values in between threshold 2 and threshold 3 are orange.
- Values above threshold 3 are red.
Network Object Chart
It is possible to monitor a specific NetworkObject
statistics by adding the NetworkObjectStatistics
component to it, a blue header for the NetworkObject
will appear on the statistics panel.
Use the toggle stats dropdown to add or remove stats to monitor, use the arrow buttons to collapse the entire NetworkObject
graph.
World Anchor
In VR scenarios, or any other scenario where it is necessary to set the statistics graphs to world position, this can be achieved by using the world anchor settings in the settings panel, enable the "Use World Anchor" checkbox to see and select a world anchor.
Add the StatisticsWorldAnchor
component to any GameObject
and it will appear as a world anchor candidate, click on the GameObject
name and the statistics panel will be re-parented to that object.
The statistics panel canvas will follow the GameObject
position, if the object is destroyed the canvas will snap back to the original position. Uncheck the "Use World Anchor" checkbox to use the canvas in overlay mode again.