Skip to content

Game.Net.LabelVertex

Assembly: Assembly-CSharp
Namespace: Game.Net

Type: struct

Base: System.ValueType, Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.IEmptySerializable

Summary:
LabelVertex is a simple, blittable buffer element used with Unity's Entities (DOTS) to represent a single vertex for label rendering. It packs vertex position, two UV sets, a material identifier (as an int2) and a 32-bit color. The type is annotated with InternalBufferCapacity(0), so dynamic buffers of this element have zero inline capacity and allocate on the heap. It is suitable for use inside jobs and entities' dynamic buffers.


Fields

  • public float3 m_Position
    Represents the vertex position in world (or local) space. Uses Unity.Mathematics.float3 for efficient job-friendly storage.

  • public float2 m_UV0
    Primary texture coordinates (UV0) for the vertex. Uses Unity.Mathematics.float2.

  • public float2 m_UV1
    Secondary texture coordinates (UV1) for the vertex. Often used for additional texture layers, lightmap coords, or special packing.

  • public int2 m_Material
    A pair of integers used to identify material or sub-material indices. The interpretation is project-specific (for example: material atlas index and sub-index).

  • public Color32 m_Color
    Vertex color stored in UnityEngine.Color32 (packed RGBA bytes). Useful for tinting label quads per-vertex.

Notes: - The struct is blittable and safe to use in Burst-compiled jobs and in dynamic buffers. - The [InternalBufferCapacity(0)] attribute indicates no inline storage — the buffer will allocate externally for any elements.

Properties

This type does not declare any properties.

Constructors

  • public LabelVertex()
    Default parameterless constructor provided by the struct. You can initialize fields inline with object initializer syntax when adding elements to a DynamicBuffer.

Methods

This type does not declare any methods.

Usage Example

using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
using Game.Net;

public partial class LabelBufferExampleSystem : SystemBase
{
    protected override void OnCreate()
    {
        base.OnCreate();
    }

    protected override void OnUpdate()
    {
        // Example: add a vertex to a buffer for a given entity (entity must exist and be set up to receive the buffer)
        Entities
            .WithStructuralChanges()
            .ForEach((Entity entity, ref SomeLabelTag tag) =>
            {
                var em = World.DefaultGameObjectInjectionWorld.EntityManager;
                // Ensure the entity has the dynamic buffer
                if (!em.HasComponent<DynamicBuffer<LabelVertex>>(entity))
                {
                    em.AddBuffer<LabelVertex>(entity);
                }

                var buffer = em.GetBuffer<LabelVertex>(entity);

                var v = new LabelVertex
                {
                    m_Position = new float3(10f, 0f, 5f),
                    m_UV0 = new float2(0f, 0f),
                    m_UV1 = new float2(1f, 1f),
                    m_Material = new int2(2, 0),
                    m_Color = new Color32(255, 200, 150, 255)
                };

                buffer.Add(v);
            }).Run();
    }
}

Notes and recommendations: - Because LabelVertex is a buffer element (IBufferElementData), prefer using DynamicBuffer in systems and jobs to append or read vertices efficiently. - The struct is suitable for Burst compiled jobs; avoid referencing managed types inside fields (Color32 is a value type and fine). - Interpret m_Material according to your mod/game renderer conventions (it is a generic int2).