Skip to content

Game.Prefabs.MarkerMarker

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
MarkerMarker is a ComponentBase used for marker/notification prefabs. It exposes a public MarkerType field (m_MarkerType) that is written into an ECS component (MarkerMarkerData) during prefab initialization. The class registers the MarkerMarkerData component for prefab entities so runtime entities created from the prefab will contain the marker data. The ComponentMenu attribute places this component under the "Notifications/" menu in the editor and associates it with NotificationIconPrefab.


Fields

  • public MarkerType m_MarkerType
    This public field defines which marker type the prefab represents. It is serialized on the MonoBehaviour/prefab and is copied into the ECS component (MarkerMarkerData.m_MarkerType) during Initialize. MarkerType is expected to be an enum or similar type defined elsewhere in the codebase that represents different marker variants.

  • private System.Diagnostics.Stopwatch m_Stopwatch
    Not present in this class. (The original template referenced a stopwatch field for a different class; MarkerMarker does not define this.)

  • private Unity.Jobs.JobHandle <producerHandle>k__BackingField
    Not present in this class. (Included in template for a different type; MarkerMarker does not define a producerHandle.)

Properties

  • This class does not declare any C# properties. All data is provided via the public field m_MarkerType and the class overrides for component registration/initialization.

Constructors

  • public MarkerMarker()
    The default parameterless constructor is used (inherited behavior). The class does not declare an explicit constructor; Unity will construct it when the component is added to a GameObject/prefab.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the MarkerMarkerData component type to the provided set as a read/write component:
  • components.Add(ComponentType.ReadWrite()); This ensures entities created from the prefab contain the MarkerMarkerData component so Initialize can set its fields.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Intentionally empty in this implementation. No additional archetype-time components are added here beyond those registered in GetPrefabComponents.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called to initialize the ECS entity corresponding to the prefab. This method:

  • Calls base.Initialize(entityManager, entity)
  • Creates a MarkerMarkerData instance and sets its m_MarkerType to the value of this.m_MarkerType
  • Writes the component data to the entity via entityManager.SetComponentData(entity, componentData) This copies the prefab-configured marker type into the runtime ECS component.

Other notes: - The class is decorated with [ComponentMenu("Notifications/", new Type[] { typeof(NotificationIconPrefab) })], making it appear under the "Notifications/" menu and linking it with NotificationIconPrefab in the editor UI. - MarkerMarker depends on the existence of MarkerMarkerData and MarkerType types; those must be defined elsewhere in the project.

Usage Example

// Attach MarkerMarker to a prefab and set m_MarkerType in the inspector.
// When the prefab's ECS entity is initialized, the MarkerMarkerData component
// on the entity will be set with the configured marker type.

public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);
    MarkerMarkerData componentData = default(MarkerMarkerData);
    componentData.m_MarkerType = m_MarkerType;
    entityManager.SetComponentData(entity, componentData);
}