Game.Prefabs.NetArrow
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
NetArrow is a prefab component used by the game's net (road/track) prefabs to provide arrow rendering data to the ECS world. It exposes a material and per-mode colors (road and track) in the inspector, declares the required ECS component types for the prefab/archetype, and initializes the NetArrowData component with the inspector colors converted to linear color space.
Fields
-
public Material m_ArrowMaterial
Holds the Unity material used to render the arrow geometry. Assigned via the prefab inspector. -
public Color m_RoadArrowColor = Color.white
Inspector-exposed color used for road arrows. Converted to linear space and stored into the NetArrowData component at Initialize. -
public Color m_TrackArrowColor = Color.white
Inspector-exposed color used for track arrows. Converted to linear space and stored into the NetArrowData component at Initialize.
Properties
- (none)
Constructors
public NetArrow()
Default parameterless constructor (compiler-generated). No special construction logic; initialization that affects ECS happens in Initialize.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the runtime component types required on the prefab instances. This implementation registers NetArrowData as a ReadWrite component so each entity instance will contain NetArrowData. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds component types that must be present in the entity archetype. This registers ArrowMaterial and ArrowPosition as ReadWrite components so the archetype contains storage for arrow material and positional data. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is converted/instantiated into the ECS world. This method sets the NetArrowData component on the entity, assigning m_RoadColor and m_TrackColor from the inspector Color fields after converting them to linear color space: - m_RoadColor = m_RoadArrowColor.linear
- m_TrackColor = m_TrackArrowColor.linear
The method calls base.Initialize(entityManager, entity) before setting component data.
Usage Example
// NetArrow is typically configured on a prefab in the editor.
// During conversion it will run Initialize and write NetArrowData on the entity.
[ComponentMenu("Net/", new Type[] { typeof(AggregateNetPrefab) })]
public class NetArrow : ComponentBase
{
// Inspector fields:
public Material m_ArrowMaterial;
public Color m_RoadArrowColor = Color.white;
public Color m_TrackArrowColor = Color.white;
public override void Initialize(EntityManager entityManager, Entity entity)
{
base.Initialize(entityManager, entity);
// Writes linear-space colors into the ECS component used at runtime
entityManager.SetComponentData(entity, new NetArrowData
{
m_RoadColor = m_RoadArrowColor.linear,
m_TrackColor = m_TrackArrowColor.linear
});
}
}
Notes: - The class depends on Unity.Entities (EntityManager, Entity, ComponentType) and UnityEngine types (Material, Color). - The inspector colors are converted to linear color space before being stored; ensure you supply colors as intended for linear rendering.