Game.Prefabs.UniqueObjectData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
Marker (tag) component used by the game's ECS to mark a prefab or entity as a "unique object". The struct is intentionally empty and annotated with StructLayout(LayoutKind.Sequential, Size = 1) so it occupies one byte (avoiding zero-size layout/interop issues). Use this component when you need to tag entities/prefabs for systems or queries that treat them as unique (for example, preventing bulk merging or identifying single-instance prefabs).
Fields
- None
This struct contains no instance fields. It is a pure marker/tag component.
Properties
- None
No properties; the type is an empty value-type marker.
Constructors
public UniqueObjectData()
Structs have an implicit default constructor. To add this marker to an entity you create a new instance (new UniqueObjectData()) and add it as component data.
Methods
- None
No methods are defined. The type only implements IComponentData and IQueryTypeParameter to be usable in ECS queries.
Usage Example
// During conversion of a GameObject prefab to an Entity:
using Unity.Entities;
using UnityEngine;
public class UniqueObjectAuthoring : MonoBehaviour, IConvertGameObjectToEntity
{
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
// Add the marker to the entity so systems can find/handle it as a unique object.
dstManager.AddComponentData(entity, new Game.Prefabs.UniqueObjectData());
}
}
// Querying entities that were marked unique:
public partial class UniqueObjectSystem : SystemBase
{
protected override void OnUpdate()
{
Entities
.WithAll<Game.Prefabs.UniqueObjectData>()
.ForEach((Entity e) =>
{
// handle unique object
}).ScheduleParallel();
}
}