Game.Prefabs.BuildingMarkerData
Assembly:
Assembly-CSharp (default Unity game assembly; may vary depending on project build)
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType, implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
A lightweight ECS component used to tag/building-prefab entities with a BuildingType classification. This marker component stores the building's type (via the BuildingType enum) so systems and queries can filter, group, or drive behavior based on that classification. As an IComponentData value type, it is blittable and suitable for use in Jobs and burst-compiled systems. The BuildingType enum is defined elsewhere in the project and determines the specific category (e.g., Residential, Commercial, Industrial, etc.).
Fields
public BuildingType m_BuildingType
Stores the building's classification. Use this field to set or read the building type when adding this component to an entity or when processing entities in systems. Default value is the enum's default (usually 0) until assigned.
Properties
- None
Constructors
public BuildingMarkerData()
Default struct constructor provided by C#. You can initialize instances with an object initializer, e.g.new BuildingMarkerData { m_BuildingType = BuildingType.Residential }
.
Methods
- None
Usage Example
// Example 1: Adding the component to an entity via EntityManager
var marker = new BuildingMarkerData { m_BuildingType = BuildingType.Residential };
entityManager.AddComponentData(buildingEntity, marker);
// Example 2: In a system using Entities.ForEach to process building markers
Entities
.WithAll<BuildingMarkerData>()
.ForEach((ref BuildingMarkerData marker) =>
{
if (marker.m_BuildingType == BuildingType.Commercial)
{
// handle commercial building logic
}
})
.Schedule();
// Example 3: In authoring conversion (Baker) when converting GameObject prefabs to entities
public class BuildingAuthoring : MonoBehaviour
{
public BuildingType buildingType;
}
public class BuildingBaker : Baker<BuildingAuthoring>
{
public override void Bake(BuildingAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.None);
AddComponent(entity, new BuildingMarkerData { m_BuildingType = authoring.buildingType });
}
}
{{ This component is intentionally minimal — it's intended as a data marker for gameplay systems. Ensure the BuildingType enum is referenced correctly and is blittable. Because it implements IQueryTypeParameter, it can also be used directly in queries where supported by the project's ECS utilities. }}