Skip to content

Game.Prefabs.NotificationIconPrefab

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

Type: class

Base: PrefabBase

Summary:
A prefab component that defines a notification icon used by the game's notification system. This class exposes serialized fields for the icon texture, textual descriptions, and display/pulse parameters. At runtime it contributes component types used by the notification entity archetype and constructs an entity archetype for instances of this prefab (stored in NotificationIconData.m_Archetype). It is intended to be used by the prefab/system initialization pipeline (LateInitialize) rather than created manually at runtime.


Fields

  • public Texture2D m_Icon
    Holds the texture used as the notification icon shown on the map/UI.

  • public string m_Description
    A short description of the notification (typically shown in UI lists or tooltips).

  • public string m_TargetDescription
    Description text specific to the target of the notification (for example, the building or object that the notification refers to).

  • public Bounds1 m_DisplaySize = new Bounds1(3f, 3f)
    Defines the display size bounds for the icon. Bounds1 is a simple min/max float container (used by the engine to represent a range). Here the default is (min=3f, max=3f), meaning a fixed display size unless changed.

  • public Bounds1 m_PulsateAmplitude = new Bounds1(0.01f, 0.1f)
    Defines the amplitude range for a pulsating animation on the icon (min and max amplitude). Defaults provide a subtle pulsation effect.

Properties

  • This class does not declare any public C# properties. All modifiable data is exposed via public fields.

Constructors

  • public NotificationIconPrefab()
    Default constructor. Default-initializes fields; notable defaults are m_DisplaySize = Bounds1(3f, 3f) and m_PulsateAmplitude = Bounds1(0.01f, 0.1f). In typical Unity usage this class is instantiated/serialized by the prefab system rather than constructed manually.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds component types required for the prefab to the provided set. This implementation calls the base and then adds NotificationIconData and NotificationIconDisplayData as read/write component types so the prefab system knows that entities created from this prefab should include those components.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds archetype component types used when creating live entities from this prefab. This implementation calls the base and then adds the Icon component type (ComponentType.ReadWrite).

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Called by the prefab initialization pipeline after basic initialization. This override calls RefreshArchetype to (re)build the entity archetype for this prefab and store it into the NotificationIconData component on the prefab entity.

  • protected virtual void RefreshArchetype(EntityManager entityManager, Entity entity)
    Gathers all ComponentBase children of this prefab, asks each for their archetype component types, builds a HashSet of those types, ensures Created and Updated marker components are present, creates an entity archetype via entityManager.CreateArchetype(...) and stores that archetype into the NotificationIconData component on the prefab entity. This is the key method that translates the prefab composition into a runtime ECS archetype used when spawning notification icon entities.

Remarks: - RefreshArchetype uses PrefabUtils.ToArray to convert the collected HashSet into an array acceptable to CreateArchetype. - The created archetype is stored in NotificationIconData.m_Archetype (so systems can instantiate entities using that archetype). - This method expects a valid EntityManager and an existing prefab Entity representing this prefab object.

Usage Example

// Example: configure a NotificationIconPrefab and initialize its archetype during setup.
// Assume `entityManager` is available and `prefabEntity` is the entity representing this prefab.

NotificationIconPrefab prefab = /* get reference to the prefab component instance */;
prefab.m_Icon = myIconTexture;
prefab.m_Description = "Power outage";
prefab.m_TargetDescription = "Affected building";
prefab.m_DisplaySize = new Bounds1(2.5f, 3.5f);
prefab.m_PulsateAmplitude = new Bounds1(0.02f, 0.08f);

// Ensure the prefab builds its runtime archetype (this will set NotificationIconData.m_Archetype on the prefab entity)
prefab.LateInitialize(entityManager, prefabEntity);

// Later a system can read NotificationIconData.m_Archetype and use EntityManager.CreateEntity(archetype) to spawn icon entities.

Notes/Tips: - This prefab is part of the game's prefab system; modifications to the fields are typically done in the editor or during prefab registration. - Do not call RefreshArchetype from worker threads — it touches EntityManager and prefab data and should be called on the main thread during initialization.