Game.Prefabs.NetNameData
Assembly: Game
Namespace: Game.Prefabs
Type: struct NetNameData
Base: System.ValueType (implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable)
Summary:
NetNameData is an ECS component that holds visual information used for network (road/track/etc.) name rendering. It stores a base color, a color used when the object is selected, and an integer material index. This component is intended to be attached to entities that require name/label rendering so rendering systems and queries can read color/material information efficiently in DOTS jobs and serialization flows.
Fields
-
public Color32 m_Color
This is the default RGBA color used for the net/name label in normal (unselected) state. Color32 stores byte components (0–255) for R, G, B and A. -
public Color32 m_SelectedColor
Color used when the associated object/entity is highlighted or selected by the player. Used to provide visual feedback for selection. -
public int m_MaterialIndex
Index identifying which material (or material variant) should be used when rendering the name/label. The meaning of this index depends on the rendering/material lookup used by the game; modders should match whatever material table or mapping the rendering system expects.
Properties
- This type declares no properties. It exposes plain public fields.
Constructors
public NetNameData()
The struct uses the implicit default constructor. Initialize fields directly when creating an instance. Example defaults are not provided in the source; set values explicitly when creating the component.
Methods
- This type declares no methods.
Usage Example
// Example showing how to create and attach NetNameData to an entity using Unity.Entities API.
using Unity.Entities;
using Unity.Mathematics; // if needed
using UnityEngine;
public class ExampleSystem : SystemBase
{
protected override void OnCreate()
{
base.OnCreate();
}
protected override void OnUpdate()
{
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
// Create an entity with a NetNameData component
var archetype = entityManager.CreateArchetype(typeof(Game.Prefabs.NetNameData));
var e = entityManager.CreateEntity(archetype);
// Set component values
var nameData = new Game.Prefabs.NetNameData
{
m_Color = new Color32(200, 200, 200, 255), // light gray
m_SelectedColor = new Color32(255, 200, 100, 255), // highlight color
m_MaterialIndex = 2 // example material index
};
entityManager.SetComponentData(e, nameData);
// Later, systems that render or query labels can read NetNameData from entities
}
}
Notes for modders: - Because NetNameData is an IComponentData, it is intended for use with the DOTS (ECS) workflow. Access it via EntityManager or in Job/System queries. - The IQueryTypeParameter implementation means the type can be used directly in query-type parameters for efficient iteration. - IEmptySerializable comes from Colossal's serialization helpers; this indicates compatibility with the game's serialization pipeline. If creating custom serialization code or prefabs, ensure you follow the game's serialization conventions for components.