Game.Prefabs.Climate.WeatherPrefab
Assembly: Game
Namespace: Game.Prefabs.Climate
Type: class
Base: PrefabBase
Summary:
Represents a weather prefab used by the Climate/Weather system. Exposes configuration for randomization layers, cloudiness range and a classification used by the ClimateSystem. On enable it collects any OverrideablePropertiesComponent instances attached to the prefab and exposes them via a read-only collection. It also declares the prefab component requirements (adds WeatherData as a read/write component).
Fields
-
public RandomizationLayer m_RandomizationLayer
Specifies which layer(s) this weather prefab participates in for randomization. Uses the nested RandomizationLayer enum (None, Cloudiness, Aurora, Season) to indicate how this prefab should be chosen/varied by the weather randomization system. -
public float2 m_CloudinessRange
A float2 (Unity.Mathematics) representing the min/max cloudiness for this weather prefab. Decorated with a MinMaxSlider(0f, 1f) attribute in the editor to allow selecting a range between 0 and 1. -
public ClimateSystem.WeatherClassification m_Classification
Classification value (from ClimateSystem) describing the type/category of this weather prefab (e.g., clear, rain, snow, etc.). Used by the climate/weather systems to group or identify weather prefabs. -
public IReadOnlyCollection<OverrideablePropertiesComponent> overrideableProperties { get; private set; }
A read-only collection populated on OnEnable containing all OverrideablePropertiesComponent components found on this prefab. Provides external code safe access to the list of overrideable properties without allowing modification of the collection reference.
Properties
public IReadOnlyCollection<OverrideablePropertiesComponent> overrideableProperties { get; private set }
Populated in OnEnable by collecting all OverrideablePropertiesComponent instances attached to the prefab. Use this to inspect or apply overrides defined on the prefab. The setter is private; external code can only read the collection.
Constructors
public WeatherPrefab()
Default parameterless constructor (implicit). Uses the default PrefabBase initialization. No custom construction logic is defined in the class source.
Methods
-
protected override void OnEnable() : System.Void
Called when the prefab becomes enabled. This override calls base.OnEnable(), gathers all OverrideablePropertiesComponent instances attached to the GameObject into a List, and exposes them as a read-only collection via the overrideableProperties property. This is where the prefab caches its overrideable property components for later use. -
public override void GetPrefabComponents(HashSet<ComponentType> components) : System.Void
Adds the prefab's required ECS component types into the provided set. This implementation calls the base method and then adds ComponentType.ReadWrite() to indicate prefabs of this type require a WeatherData component (read/write) on their associated entity.
Usage Example
// This demonstrates that OnEnable collects OverrideablePropertiesComponent instances.
// No constructor or explicit setup required — the engine will call OnEnable().
protected override void OnEnable()
{
base.OnEnable();
// After this runs, overrideableProperties contains any OverrideablePropertiesComponent on this prefab.
if (overrideableProperties != null)
{
foreach (var prop in overrideableProperties)
{
// Inspect or initialize overrideable properties as needed
Debug.Log($"Found overrideable property component: {prop.name}");
}
}
}
// When the prefab system queries component requirements:
var components = new HashSet<ComponentType>();
myWeatherPrefab.GetPrefabComponents(components);
// components now contains ComponentType.ReadWrite<WeatherData>()
Additional notes: - The nested RandomizationLayer enum defines how the prefab participates in randomization: - None: no randomization layer - Cloudiness: included in cloudiness-based randomization - Aurora: included in aurora-related randomization - Season: included in season-based randomization - The MinMaxSlider attribute on m_CloudinessRange is an editor helper and clamps UI input to the [0, 1] range.