Game.VehicleInfomodePrefab
Assembly:
Namespace: Game.Prefabs
Type: class
Base: ColorInfomodeBasePrefab
Summary:
Prefab component that configures the vehicle infomode visualization. This prefab exposes a VehicleType (m_Type) and, on initialization, ensures the created entity receives an InfoviewVehicleData component populated with the selected vehicle type and the prefab color (m_Color). The class is marked with a ComponentMenu attribute so it can be added via the Unity editor menus for infomode tools.
Fields
public VehicleType m_Type
Used to specify which vehicle type the infomode should represent. When the prefab is initialized into an entity, this value is written into the InfoviewVehicleData component so the infomode system knows which vehicle category to color/highlight.
Properties
- (none declared on this type)
All relevant data is exposed via the public field m_Type and inherited members (for example, m_Color is provided by the ColorInfomodeBasePrefab).
Constructors
public VehicleInfomodePrefab()
Default constructor (implicitly provided). Prefab instances are typically created and configured in the Unity editor or by prefab instantiation; no special construction logic is implemented in this class.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Collects component types that this prefab will require on the created entity. This override calls the base implementation and then adds ComponentType.ReadWrite() so entities created from this prefab include the InfoviewVehicleData component. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is materialized into an entity. This override calls the base Initialize then sets the InfoviewVehicleData component on the entity with: - m_Type set to this prefab's m_Type
- m_Color set to the prefab's m_Color converted to a float4 (r,g,b,a)
This method ensures the ECS entity receives the correct data for the infomode rendering/system.
Usage Example
// Example: the prefab's Initialize implementation (as in the source)
public override void Initialize(EntityManager entityManager, Entity entity)
{
base.Initialize(entityManager, entity);
entityManager.SetComponentData(entity, new InfoviewVehicleData
{
m_Type = m_Type,
m_Color = new float4(m_Color.r, m_Color.g, m_Color.b, m_Color.a)
});
}
// Example use in editor:
// 1. Create a VehicleInfomodePrefab asset in the Unity editor (via the ComponentMenu attribute).
// 2. Set m_Type in the inspector to the desired VehicleType and set the color.
// 3. When the prefab is instantiated at runtime, the entity will receive InfoviewVehicleData
// populated with the configured vehicle type and color.