Skip to content

Game.Prefabs.UIPollutionConfigurationPrefab

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
UIPollutionConfigurationPrefab is a prefab authoring class used by the game to supply UI-related pollution thresholds to the ECS world. It exposes three public UIPollutionThresholds fields (ground, air, and noise) that can be edited in the inspector. During prefab conversion/registration it adds the UIPollutionConfigurationData component type to the prefab's component set so that the runtime ECS can create and populate the corresponding data component for entities instantiated from this prefab. The class is annotated with [ComponentMenu("Settings/", ...)] so it appears under the Settings menu in the component menu.


Fields

  • public UIPollutionThresholds m_GroundPollution
    Holds threshold values used by the UI for ground pollution (e.g., breakpoints for coloring, warnings, slider limits). Public to allow editing in the inspector and to be read when converting the prefab into ECS data.

  • public UIPollutionThresholds m_AirPollution
    Holds threshold values used by the UI for air pollution.

  • public UIPollutionThresholds m_NoisePollution
    Holds threshold values used by the UI for noise pollution.

Properties

  • None declared on this type. (All configuration values are exposed as public fields.)

Constructors

  • public UIPollutionConfigurationPrefab()
    Implicit parameterless constructor provided by the runtime/Unity. No custom construction logic is defined in this class.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Overrides PrefabBase.GetPrefabComponents to register the ECS component type required by this prefab. This implementation calls the base method and then adds ComponentType.ReadWrite() to the provided components set. That ensures prefab instances will include a UIPollutionConfigurationData component (read/write) so systems can access and modify the UI pollution configuration at runtime.

Parameters: - components: HashSet — the set of component types collected for the prefab. This method appends UIPollutionConfigurationData to that set.

Usage Example

// Example: during prefab conversion you would read the thresholds from the prefab
// and write them into the ECS data component. The exact conversion hooks depend
// on the game's conversion pipeline; this is an illustrative snippet.

protected void ConvertUIPollutionConfigurationPrefab(UIPollutionConfigurationPrefab prefab, Entity entity, Unity.Entities.EntityManager dstManager)
{
    // Create/populate the runtime data structure (fields depend on UIPollutionConfigurationData definition)
    var data = new UIPollutionConfigurationData
    {
        Ground = prefab.m_GroundPollution,
        Air = prefab.m_AirPollution,
        Noise = prefab.m_NoisePollution
    };

    // Add the data to the entity so systems can read the UI thresholds
    dstManager.AddComponentData(entity, data);
}

Notes and tips: - UIPollutionThresholds and UIPollutionConfigurationData types must be defined elsewhere in the codebase. UIPollutionThresholds typically contains numeric breakpoints and color/label info used by UI rendering code. - Because the prefab adds ComponentType.ReadWrite(), ensure any systems that expect this component use the corresponding component type name and layout. - Use the inspector to tweak the public m_GroundPollution / m_AirPollution / m_NoisePollution fields on the prefab asset; those values will be carried into the runtime data during conversion/instantiation.