Skip to content

Game.Prefabs.NetGeometrySection

Assembly:
(not specified in source)

Namespace:
Game.Prefabs

Type:
struct NetGeometrySection

Base:
IBufferElementData, IEmptySerializable

Summary:
NetGeometrySection is a DOTS/ECS buffer element used to store per-section geometry information for network prefabs (e.g., road/track sections). It holds a reference to the section entity, composition flag bitfields used for filtering/selection, section-specific flags, and a local offset (float3). The type is annotated with [InternalBufferCapacity(0)], making it a dynamic buffer element with an initial capacity of zero.


Fields

  • public Entity m_Section
    Reference to the Entity representing the associated geometry section. This allows linking to another entity that contains the detailed mesh/rendering components for this section.

  • public CompositionFlags m_CompositionAll
    Bitfield representing flags that must all be present for the section to match a composition filter. (CompositionFlags is a game-specific enum/bitmask defined elsewhere.)

  • public CompositionFlags m_CompositionAny
    Bitfield representing flags where any single matching bit will satisfy the composition filter.

  • public CompositionFlags m_CompositionNone
    Bitfield representing flags that must be absent for the section to match a composition filter.

  • public NetSectionFlags m_Flags
    Flags describing section-specific properties (a game-specific enum/bitmask defined elsewhere). Typical uses: rendering, physics, LOD behavior, or other per-section toggles.

  • public float3 m_Offset
    Local offset (Unity.Mathematics.float3) applied to the section's geometry relative to its parent/pivot.

Properties

  • (none declared)

Constructors

  • (no explicit constructors declared)
    As a value-type (struct) this type has the implicit parameterless constructor. Instances are typically created and populated when adding buffer elements via EntityManager / System APIs.

Methods

  • (none declared)

Usage Example

using Unity.Entities;
using Unity.Mathematics;
using Game.Prefabs;

// Example inside a System or setup routine
public void AddSectionToPrefab(EntityManager entityManager, Entity prefabEntity, Entity sectionEntity)
{
    // Ensure the buffer exists on the prefab entity
    var buffer = entityManager.HasComponent<DynamicBuffer<NetGeometrySection>>(prefabEntity)
        ? entityManager.GetBuffer<NetGeometrySection>(prefabEntity)
        : entityManager.AddBuffer<NetGeometrySection>(prefabEntity);

    // Create and add a new section entry
    NetGeometrySection entry = new NetGeometrySection
    {
        m_Section = sectionEntity,
        m_CompositionAll = CompositionFlags.None,   // set appropriately
        m_CompositionAny = CompositionFlags.None,   // set appropriately
        m_CompositionNone = CompositionFlags.None,  // set appropriately
        m_Flags = NetSectionFlags.None,             // set appropriate flags
        m_Offset = new float3(0f, 0f, 0f)
    };

    buffer.Add(entry);
}

Notes and tips: - InternalBufferCapacity(0) indicates the buffer is created with zero inline storage and will allocate on the heap as elements are added. This reduces the footprint on the Entity but may cause allocations when first populated. - CompositionFlags and NetSectionFlags are game-specific enums/bitmasks; consult their definitions to set appropriate values. - Because this is an IBufferElementData, you should access and modify instances via DynamicBuffer in systems rather than treating them as standalone components.