Skip to content

Game.Prefabs.NetLabel

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
NetLabel is a prefab component used for rendering and configuring network (road/rail/etc.) name labels. It exposes a material and two colors (normal and selected) which are converted to linear color space and stored into an ECS component (NetNameData) during initialization. The class also declares which ECS components should be present on the prefab/archetype so label rendering systems have the data they need (LabelMaterial, LabelExtents, LabelPosition, LabelVertex and NetNameData).


Fields

  • public Material m_NameMaterial
    This Material is intended for rendering the name label. Set this in the prefab or inspector to control the appearance (shader, texture, etc.) used for net labels.

  • public Color m_NameColor = Color.white
    Default color for the label in sRGB; converted to linear space in Initialize and stored in NetNameData.m_Color.

  • public Color m_SelectedNameColor = new Color(0.5f, 0.75f, 1f, 1f)
    Color used when the net/label is selected. Also converted to linear space in Initialize and stored in NetNameData.m_SelectedColor.

Properties

  • None declared on this component. The class only exposes public fields to be configured on the prefab/inspector.

Constructors

  • public NetLabel()
    No explicit constructor is defined in the source; the default parameterless constructor is used. Initialization work that needs ECS data setup is performed in the Initialize override rather than a constructor.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds NetNameData (read/write) to the provided set. This tells the prefab subsystem that entities created from this prefab must include NetNameData so the label color data can be stored.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds the following read/write component types to the archetype component set: LabelMaterial, LabelExtents, LabelPosition, and LabelVertex. These are required for the label rendering pipeline (geometry, position, material reference, etc.).

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab's entity is initialized. This override sets the NetNameData component on the entity with the configured colors converted to linear color space:

  • NetNameData.m_Color = m_NameColor.linear
  • NetNameData.m_SelectedColor = m_SelectedNameColor.linear This ensures the ECS-side label color data is in the correct color space for rendering.

Usage Example

// Example: customizing a NetLabel on a prefab or in code
public class MyCustomNetLabel : NetLabel
{
    public override void Initialize(EntityManager entityManager, Entity entity)
    {
        // Optionally tweak colors/material before base initialization
        m_NameColor = Color.yellow;
        m_SelectedNameColor = new Color(1f, 0.85f, 0.3f, 1f);

        base.Initialize(entityManager, entity);
        // After base.Initialize, NetNameData on the entity will have been set
        // with the linear-space colors.
    }
}