Game.Prefabs.NotificationIconDisplayData
Assembly: Game
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType
Summary:
NotificationIconDisplayData is a lightweight ECS component struct used to describe display parameters for a notification icon prefab. It stores a min/max parameter range (float2), an icon index, and a category mask. The type implements Unity.Entities IComponentData and several serialization/query-related interfaces so it can be used in queries, be enabled/disabled per-entity, and be serialized with the Colossal serialization system. Its custom serialization writes only the midpoint of the min/max range; deserialization reads a single float2 and assigns it to both min and max, and initializes other fields with defaults.
Fields
-
public Unity.Mathematics.float2 m_MinParams
Stores the minimum parameter values for the notification icon (two-component vector). During serialization the midpoint between this and m_MaxParams is written; during deserialization this field is read and used as the sole stored parameter. -
public Unity.Mathematics.float2 m_MaxParams
Stores the maximum parameter values for the notification icon (two-component vector). Note: Serialize writes the midpoint of m_MinParams and m_MaxParams. Deserialize sets this field equal to the read m_MinParams (so min == max after deserialization). -
public int m_IconIndex
Index of the icon to display. Deserialize sets this to 0 by default. -
public uint m_CategoryMask
Mask representing categories for the notification. Deserialize initializes this to 2147483648u (0x80000000).
Properties
- This type does not declare any C# properties. It uses public fields for data storage and implements behavior via interfaces.
Constructors
public NotificationIconDisplayData()
Structs in C# have an implicit parameterless constructor that zero-initializes fields. No explicit constructors are declared in the type.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the midpoint of m_MinParams and m_MaxParams to the provided writer: writer.Write((m_MinParams + m_MaxParams) * 0.5f); -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads a float2 from the reader into m_MinParams, then sets: m_MaxParams = m_MinParams; m_IconIndex = 0; m_CategoryMask = 2147483648u; // 0x80000000
Behavior notes: - The serialization strategy is lossy for the min/max pair: only the average is persisted. After deserialization both min and max will be equal (the stored value). - The generic Serialize/Deserialize methods require writer/reader types that implement the IWriter/IReader interfaces from the Colossal.Serialization framework.
Usage Example
// Create and initialize the component
var data = new NotificationIconDisplayData
{
m_MinParams = new float2(0.2f, 0.4f),
m_MaxParams = new float2(0.6f, 0.8f),
m_IconIndex = 3,
m_CategoryMask = 0x1u
};
// What Serialize will write (the midpoint)
float2 midpoint = (data.m_MinParams + data.m_MaxParams) * 0.5f; // (0.4, 0.6)
// After Deserialize(reader) where reader supplies midpoint:
// data.m_MinParams == midpoint
// data.m_MaxParams == midpoint
// data.m_IconIndex == 0
// data.m_CategoryMask == 2147483648u (0x80000000)
{{ Additional notes: - Because this component implements IEnableableComponent, it can be enabled/disabled per-entity in Unity's ECS. - IQueryTypeParameter allows this type to be used as a parameter in query APIs. - The choice to serialize only the midpoint is likely an intentional size/storage optimization; be aware this will not preserve the original range. }}