Skip to content

Game.Prefabs.VehicleMarker

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
VehicleMarker is a Unity/EC S prefab component used by notification/icon prefabs to tag spawned entities with VehicleMarkerData. In the editor it exposes a public VehicleType (m_VehicleType) which is written into the corresponding ECS component during prefab initialization. This allows runtime systems to identify the vehicle type associated with a notification/marker entity.


Fields

  • public VehicleType m_VehicleType
    This public field is set on the prefab (Inspector). During Initialize it is copied into the VehicleMarkerData component on the created entity so ECS systems can read which VehicleType this marker represents.

Properties

  • (none)
    This component does not expose any C# properties.

Constructors

  • public VehicleMarker()
    Default parameterless constructor provided by the class. No custom construction logic is present.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the runtime component type that this prefab requires. Implementation adds ComponentType.ReadWrite<VehicleMarkerData>(), meaning entities created from this prefab will have a writable VehicleMarkerData component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    No archetype components are added by this implementation (method is empty). Archetype-level requirements are not modified here.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab is instantiated into the ECS world. This override:

  • Calls the base Initialize.
  • Creates a VehicleMarkerData value, copies the prefab's m_VehicleType into it, and writes it to the entity via entityManager.SetComponentData(entity, componentData); This transfers the inspector-assigned vehicle type into the ECS component instance.

Usage Example

// Typical prefab behavior: the inspector sets m_VehicleType.
// When the prefab is instantiated, Initialize will be called and will write this
// value into the ECS component VehicleMarkerData on the created entity.

[Preserve]
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);
    var componentData = new VehicleMarkerData { m_VehicleType = this.m_VehicleType };
    entityManager.SetComponentData(entity, componentData);
}

// Reading the value from systems:
var markerData = entityManager.GetComponentData<VehicleMarkerData>(entity);
if (markerData.m_VehicleType == VehicleType.Bus) {
    // handle bus-specific marker logic
}