Skip to content

Game.UI.Editor.DiversityPanelSystem

Assembly: Game
Namespace: Game.UI.Editor

Type: class

Base: EditorPanelSystemBase

Summary:
This editor UI system provides a "Diversity" panel for the in-game editor that allows selecting atmosphere and biome presets (prefabs). It wires up prefab pickers for AtmospherePrefab and BiomePrefab, reads current settings from simulation singletons on start, and applies chosen presets via the DiversitySystem. The system uses PrefabSystem to resolve prefabs and EntityQuery to read AtmosphereData and BiomeData singletons.


Fields

  • private PrefabSystem m_PrefabSystem
    Holds a reference to the PrefabSystem used to resolve prefab types and entities for chosen atmosphere/biome prefabs.

  • private DiversitySystem m_DiversitySystem
    Reference to the game DiversitySystem which is used to apply atmosphere and biome presets to the simulation.

  • private EntityQuery m_AtmosphereQuery
    EntityQuery configured to read AtmosphereData. Used to obtain the current atmosphere prefab ID from the simulation singleton.

  • private EntityQuery m_BiomeQuery
    EntityQuery configured to read BiomeData. Used to obtain the current biome prefab ID from the simulation singleton.

  • private AtmospherePrefab m_Atmosphere
    The currently selected AtmospherePrefab instance displayed/edited by the panel.

  • private BiomePrefab m_Biome
    The currently selected BiomePrefab instance displayed/edited by the panel.

Properties

  • (none)

Constructors

  • public DiversityPanelSystem()
    Parameterless constructor. Marked with [Preserve] attribute in the implementation to prevent stripping. Most initialization occurs in OnCreate and OnStartRunning.

Methods

  • protected override void OnCreate()
    Initializes UI widgets and internal system references. Obtains PrefabSystem and DiversitySystem from World, creates EntityQueries for AtmosphereData and BiomeData, sets the panel title to the localized "Diversity" string, and constructs the children widget tree (a scrollable section containing popup pickers for Atmosphere and Biome prefabs). This method sets up DelegateAccessor callbacks to SetAtmosphere and SetBiome.

  • protected override void OnStartRunning()
    Called when the system starts running. Reads AtmosphereData and BiomeData singletons via the entity queries, resolves their prefab IDs into AtmospherePrefab and BiomePrefab instances using PrefabSystem.TryGetPrefab, and assigns them to m_Atmosphere and m_Biome so the UI shows the current simulation presets.

  • private void SetAtmosphere(PrefabBase prefab)
    Callback used by the Atmosphere popup picker. Casts the selected PrefabBase to AtmospherePrefab, resolves its Entity via PrefabSystem.GetEntity, and calls DiversitySystem.ApplyAtmospherePreset(entity) to apply the chosen atmosphere preset to the simulation.

  • private void SetBiome(PrefabBase prefab)
    Callback used by the Biome popup picker. Casts the selected PrefabBase to BiomePrefab, resolves its Entity via PrefabSystem.GetEntity, and calls DiversitySystem.ApplyBiomePreset(entity) to apply the chosen biome preset to the simulation.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // The system creates widget children, configures queries and references:
    m_PrefabSystem = base.World.GetOrCreateSystemManaged<PrefabSystem>();
    m_DiversitySystem = base.World.GetOrCreateSystemManaged<DiversitySystem>();
    m_AtmosphereQuery = GetEntityQuery(ComponentType.ReadOnly<AtmosphereData>());
    m_BiomeQuery = GetEntityQuery(ComponentType.ReadOnly<BiomeData>());
    title = LocalizedString.Value("Diversity");
    // The UI contains popup pickers that call SetAtmosphere and SetBiome when changed.
}

Additional notes: - The system expects AtmosphereData and BiomeData singletons to exist in the world; OnStartRunning reads them to initialize the UI to the current simulation state. - SetAtmosphere/SetBiome rely on PrefabSystem to map prefabs to entities; those entity handles are passed to DiversitySystem.ApplyAtmospherePreset / ApplyBiomePreset to enact the change.