Game.Prefabs.IconConfigurationPrefab
Assembly:
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
Prefab class that contains configuration for notification icons used by the game UI. Exposed in the Unity Component menu under "Settings/". Stores a material, references to marker prefabs (selected and followed), an array of icon animation descriptions, and a fallback "missing" icon texture. Integrates with the ECS prefab pipeline by declaring required component types and writing IconConfigurationData and IconAnimationElement buffer entries during LateInitialize so runtime systems can consume the configured icon entities and animation data.
Fields
-
public UnityEngine.Material m_Material
Used material for icons. May be used by rendering systems that display notification icons. -
public NotificationIconPrefab m_SelectedMarker
Prefab reference for the "selected" notification marker. Added as a prefab dependency and resolved to an Entity during LateInitialize. -
public NotificationIconPrefab m_FollowedMarker
Prefab reference for the "followed" notification marker. Added as a prefab dependency and resolved to an Entity during LateInitialize. -
public IconAnimationInfo[] m_Animations
Array of animation descriptions (duration, curves, and type). During LateInitialize each entry is converted to an IconAnimationElement and written into the entity's dynamic buffer of IconAnimationElement. -
public UnityEngine.Texture2D m_MissingIcon
Fallback texture used when a specific icon texture is not available.
Properties
- This class does not declare any properties.
Constructors
public IconConfigurationPrefab()
No explicit constructor is defined in the source; the default parameterless constructor is used. Initialization of runtime ECS data is performed in the LateInitialize override rather than a constructor.
Methods
-
public override void GetDependencies(System.Collections.Generic.List<PrefabBase> prefabs)
Adds referenced marker prefabs (m_SelectedMarker and m_FollowedMarker) to the supplied dependency list so the prefab loading system knows about these dependencies. -
public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Adds the runtime ECS component types used by this prefab: ComponentType.ReadWrite() and ComponentType.ReadWrite (). This informs the prefab system which components/buffers to create for the prefab entity. -
public override void LateInitialize(Unity.Entities.EntityManager entityManager, Unity.Entities.Entity entity)
Resolves the referenced marker prefabs to Entities using the PrefabSystem (existingSystemManaged.GetEntity(m_SelectedMarker) / GetEntity(m_FollowedMarker)) and writes those into an IconConfigurationData component on the prefab entity. If m_Animations is not null it converts each IconAnimationInfo into an IconAnimationElement (including creating an AnimationCurve3 from the described scale/alpha/screenY curves) and stores them into the entity's DynamicBuffer. The method ensures the buffer is resized/filled with default elements as necessary so the element for the animation type index exists; if an index already exists it overwrites it.
Notes and behavior details:
- If m_Animations is null, no animation elements are written.
- Animation entries are indexed by (int)iconAnimationInfo.m_Type; the code ensures buffer length and inserts/overwrites at that index.
- PrefabSystem is retrieved with entityManager.World.GetExistingSystemManaged
Usage Example
// This example mirrors what the prefab system does when initializing an icon configuration prefab.
// The game's prefab loader will call LateInitialize for you; you generally do not call this manually.
public override void LateInitialize(EntityManager entityManager, Entity entity)
{
base.LateInitialize(entityManager, entity);
// Resolve referenced prefabs to entities
PrefabSystem prefabSystem = entityManager.World.GetExistingSystemManaged<PrefabSystem>();
IconConfigurationData config = default;
config.m_SelectedMarker = prefabSystem.GetEntity(m_SelectedMarker);
config.m_FollowedMarker = prefabSystem.GetEntity(m_FollowedMarker);
entityManager.SetComponentData(entity, config);
// Convert configured animation infos into the IconAnimationElement buffer
if (m_Animations != null)
{
DynamicBuffer<IconAnimationElement> buffer = entityManager.GetBuffer<IconAnimationElement>(entity);
for (int i = 0; i < m_Animations.Length; i++)
{
var info = m_Animations[i];
var element = new IconAnimationElement
{
m_Duration = info.m_Duration,
m_AnimationCurve = new AnimationCurve3(info.m_Scale, info.m_Alpha, info.m_ScreenY)
};
int index = (int)info.m_Type;
if (buffer.Length > index)
{
buffer[index] = element;
}
else
{
while (buffer.Length < index) buffer.Add(default(IconAnimationElement));
buffer.Add(element);
}
}
}
}