Skip to content

Game.Prefabs.StatisticsData

Assembly: Game
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
StatisticsData is a lightweight ECS component (IComponentData) used to describe a UI/game statistic entry within the prefab layer. It holds entity references for categorization and grouping, enumerated types that define what statistic is shown and how it is collected/united, a display color, and a flag controlling stacked rendering. Because it implements IQueryTypeParameter it can be used directly in queries/patterns where this component type is expected.


Fields

  • public Entity m_Category
    Reference to an Entity that represents the category this statistic belongs to (e.g., Economy, Population). Use this to link to category metadata or grouping entities.

  • public Entity m_Group
    Reference to an Entity used to group related statistics together (for example for aggregation or UI grouping).

  • public StatisticType m_StatisticType
    Enum value identifying the specific statistic this component represents (e.g., Income, Unemployment). Determines which data stream or value should be displayed.

  • public StatisticCollectionType m_CollectionType
    Enum describing how the statistic is collected or sampled (for example instant, cumulative, averaged). Affects how data is aggregated/queried.

  • public StatisticUnitType m_UnitType
    Enum indicating the unit type of the statistic (for example Count, Percentage, Currency). Useful for display formatting and axis labeling.

  • public Color m_Color
    UnityEngine.Color used for UI rendering (chart color, legend color, etc.) to visually identify the statistic.

  • public bool m_Stacked
    When true, this statistic should be rendered as part of a stacked representation (stacked bar/area chart). When false, render independently.

Properties

  • This type does not define any C# properties. All data is exposed as public fields.

Constructors

  • public StatisticsData()
    This struct relies on the default value-type constructor. Initialize fields explicitly when creating an instance (see example).

Methods

  • This struct does not declare any methods.

Usage Example

using Unity.Entities;
using UnityEngine;
using Game.Prefabs;

// Example: create an entity and attach a StatisticsData component
public void CreateStatistic(EntityManager entityManager, Entity categoryEntity, Entity groupEntity)
{
    var statEntity = entityManager.CreateEntity();

    var statData = new StatisticsData
    {
        m_Category = categoryEntity,
        m_Group = groupEntity,
        m_StatisticType = StatisticType.Income,           // example enum value
        m_CollectionType = StatisticCollectionType.Sum,   // example enum value
        m_UnitType = StatisticUnitType.Currency,          // example enum value
        m_Color = Color.green,
        m_Stacked = false
    };

    entityManager.AddComponentData(statEntity, statData);
}

Notes: - Ensure referenced Entities (m_Category, m_Group) exist and remain valid for the lifetime of this component usage. - Enum names (StatisticType, StatisticCollectionType, StatisticUnitType) are placeholders that match the project's definitions; consult the project's enum definitions for available values. - Use EntityManager or SystemBase to create/query entities and read/write this component in DOTS systems.