メインコンテンツまでスキップ

統計データプロファイルメニュー UI - 統計データを追跡し表示する - (Unity モジュール)

Last updated on June 23, 2025

What's on the Menu

In this section, you'll learn how to prepare UIs to display player statistics values. These UIs are defined in the following classes:

  • StatsProfileMenu_Starter: A C# class used to display statistical values and categories.

    • CS file: Assets/Resources/Modules/StatsEssentials/Scripts/UI/StatsProfileMenu_Starter.cs
    • Prefab file: Assets/Resources/Modules/StatsEssentials/Prefabs/StatsProfileMenu_Starter.prefab
  • StatsProfileEntry: A C# class used to display individual statistical values.

    • CS file: Assets/Resources/Modules/PartyEssentials/Scripts/UI/StatsProfileEntry.cs
    • Prefab file: Assets/Resources/Modules/PartyEssentials/Prefabs/StatsProfileEntry.prefab

Take a closer look at how these UIs are constructed.

Stats Profile Widget

Below is a preview of the StatsProfileMenu_Starter prefab. This prefab includes tab menus that display statistical values based on game modes.

StatsProfileMenu_Starter preview image Unity Byte Wars stat tracking

The components used in this menu are defined in the StatsProfileMenu_Starter class. The widgetSwitcher is a helper component used to display the menu state (e.g., loading, error, empty result, or result). Each statistical value is categorized into different panels based on the game modes. These panels are organized using the statsPanelList helper variable.

[SerializeField] private AccelByteWarsWidgetSwitcher widgetSwitcher;
[SerializeField] private StatsProfileEntry statsEntryPrefab;
[SerializeField] private Transform singlePlayerStatsPanel;
[SerializeField] private Transform eliminationPlayerStatsPanel;
[SerializeField] private Transform teamDeathmatchPlayerStatsPanel;
[SerializeField] private Button backButton;

Stats Profile Widget Entry

Below is a preview of the StatsProfileEntry prefab. This prefab is used to display a statistic's name and its value.

StatsProfileEntry preview image Unity Byte Wars stat tracking

The components used in this widget are defined in the StatsProfileEntry class.

[SerializeField] private TMP_Text statNameText;
[SerializeField] private TMP_Text statValueText;

Ready the UI

In this section, you are going to prepare the menus mentioned earlier to start integrating the statistics.

  1. Open the StatsProfileMenu_Starter class and create a new function below. Later, you will revisit this function to send requests to get player statistics values from AGS. For now, add the code below to switch the menu to the loading state.

    private void DisplayStats()
    {
    widgetSwitcher.SetWidgetState(AccelByteWarsWidgetSwitcher.WidgetState.Loading);
    }
  2. In the OnEnable() function when the menu is displayed, call the function above.

    void OnEnable()
    {
    DisplayStats();
    }
  3. In the Unity editor, go to Assets/Resources/Modules/StatsEssentials and open the StatsEssentialsAssetConfig.asset. Then, make sure to activate the module in starter mode by ticking the Is Active checkbox and the Is Starter Active checkbox.

  4. Next, play the game in the editor. You'll be able to navigate to Main Menu > Profile > Stats menu.

Resources