Game.Prefabs.LevelStatistic
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: class
Base: ParametricStatistic
Summary:
LevelStatistic is a small ParametricStatistic component used by the statistics/prefab system to expose one statistic parameter per LevelInfo stored in its m_Levels array. It is decorated with the ComponentMenu attribute so it can be added from the "Statistics/" component menu. For each LevelInfo entry it yields a StatisticParameterData constructed from the entry's m_Value and a black Color; parameter names are returned as the numeric index (ToString()).
Fields
public LevelInfo[] m_Levels
Holds the list/array of LevelInfo entries that drive the statistic parameters. Each LevelInfo's m_Value is used to create a StatisticParameterData. The array is null-checked in GetParameters(); if null, no parameters are returned.
Properties
- This class does not declare any properties.
Constructors
public LevelStatistic()
Default parameterless constructor. Instances are created by Unity when the component is added to a GameObject; the class does not perform any custom initialization in the constructor.
Methods
public override IEnumerable<StatisticParameterData> GetParameters()
Returns an enumerator that yields a StatisticParameterData for each LevelInfo in m_Levels. Implementation notes:- If m_Levels is null, the method yields nothing.
- For each LevelInfo it yields
new StatisticParameterData(levelInfo.m_Value, Color.black)
. -
Uses yield return so enumeration is lazy.
-
public override string GetParameterName(int parameter)
Returns the string representation of the parameter index:parameter.ToString()
. This method is used to provide a name/label for each parameter produced by GetParameters.
Usage Example
// Suppose 'stat' is a reference to a LevelStatistic component on a GameObject (set via inspector or GetComponent).
LevelStatistic stat = /* reference from scene */;
foreach (var param in stat.GetParameters())
{
Debug.Log($"Parameter value: {param.value}, color: {param.color}");
}
// If you need parameter names:
int i = 0;
foreach (var _ in stat.GetParameters())
{
Debug.Log($"Parameter {i}: {stat.GetParameterName(i)}");
i++;
}
Additional notes: - The class is intended to be configured via the inspector by assigning LevelInfo elements to m_Levels. - LevelInfo is expected to contain a field m_Value (used here); consult the LevelInfo definition for its structure and semantics.