Game.Prefabs.LaneDirectionObject
Assembly:
(assembly not specified in source — typically Assembly-CSharp for game scripts)
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Prefab component used to provide lane-direction configuration (left / forward / right) to an ECS entity during prefab initialization. Adds the required ECS component types for lane direction data and ensures the LaneDirectionData component on the entity is initialized from the serialized fields. Typically used on static or marker object prefabs that need lane direction metadata.
Fields
-
public LaneDirectionType m_Left = LaneDirectionType.None
Left-turn lane direction value serialized on the prefab. During LateInitialize this value is copied into the entity's LaneDirectionData.m_Left. Default is LaneDirectionType.None. -
public LaneDirectionType m_Forward
Forward lane direction value serialized on the prefab. This value is copied into LaneDirectionData.m_Forward during LateInitialize. No explicit initializer in source (uses the enum default if not set in inspector). -
public LaneDirectionType m_Right = LaneDirectionType.None
Right-turn lane direction value serialized on the prefab. Copied into LaneDirectionData.m_Right during LateInitialize. Default is LaneDirectionType.None.
Properties
- (none)
Constructors
public LaneDirectionObject()
Implicit parameterless constructor (not declared in source). The class relies on Unity/serialization to populate fields when used as a prefab component.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds ComponentType.ReadWrite() to the provided components set. This indicates that entities created from this prefab will include a LaneDirectionData component (read/write). -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds ComponentType.ReadWrite() to the archetype components set. Ensures the entity archetype includes the NetObject component (from Game.Objects) when this prefab is instantiated. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Called after entity creation to initialize component data. This method: - Calls base.LateInitialize(entityManager, entity).
- Constructs a LaneDirectionData instance, copies m_Left, m_Forward, and m_Right into it.
- Writes the LaneDirectionData to the entity via entityManager.SetComponentData(entity, componentData).
Notes: - The class is annotated with [ComponentMenu("Objects/", typeof(StaticObjectPrefab), typeof(MarkerObjectPrefab))], indicating how it appears in the editor component menu and intended use on static/marker prefabs. - This component assumes the existence of a LaneDirectionData struct and Game.Objects.NetObject component type in the project's ECS definitions.
Usage Example
// Typical prefab usage: the fields (m_Left/m_Forward/m_Right) are set in the prefab inspector.
// When the prefab creates an ECS entity, LateInitialize will run and write the LaneDirectionData.
// Example showing conceptually what LateInitialize does:
protected override void LateInitialize(EntityManager entityManager, Entity entity)
{
base.LateInitialize(entityManager, entity);
var data = default(LaneDirectionData);
data.m_Left = m_Left;
data.m_Forward = m_Forward;
data.m_Right = m_Right;
entityManager.SetComponentData(entity, data);
}