Game.Prefabs.DefaultPolicyData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: Unity.Entities.IBufferElementData
Summary:
A simple ECS buffer element that holds a reference to a policy Entity used as a "default" policy on a prefab. The struct is marked with [InternalBufferCapacity(0)], indicating an initially empty/dynamic buffer (no inline storage). It is intended for use in prefab conversion or components that need to store one or more policy Entity references per entity.
Fields
public Unity.Entities.Entity m_Policy
Holds the Entity reference for the default policy. This is a plain public field so it can be read/written when operating on the DynamicBuffer. The type is Unity.Entities.Entity (a value type representing an entity reference in DOTS).
Properties
- None
This type exposes no properties; it is a plain IBufferElementData struct with a single public field.
Constructors
public DefaultPolicyData(Entity policy)
Initializes the buffer element and sets m_Policy to the provided Entity. Useful when adding elements to a DynamicBuffer.
Methods
- None
This type contains no methods beyond the generated value-type members.
Usage Example
// Add a policy to an entity's DefaultPolicyData buffer
var buffer = entityManager.GetBuffer<DefaultPolicyData>(targetEntity);
buffer.Add(new DefaultPolicyData(policyEntity));
// Or during conversion (IConvertGameObjectToEntity / IDeclareReferencedPrefabs pattern)
// you can add DefaultPolicyData elements to the entity created from a prefab.
Additional notes: - Because DefaultPolicyData implements IBufferElementData and is a blittable struct containing only an Entity, it is safe and efficient for DOTS/ECS use. - The [InternalBufferCapacity(0)] attribute indicates that the buffer has no inline storage in the entity; elements are stored externally and the buffer starts empty. This is appropriate when most entities do not have default policies or when you expect variable counts.