Game.Prefabs.NetLaneGeometryPrefab
Assembly:
Namespace: Game.Prefabs
Type: public class
Base: NetLanePrefab
Summary:
Prefab component that supplies geometry-related data and required components for road/track lanes. It exposes an array of NetLaneMeshInfo entries (m_Meshes) and implements logic to declare prefab dependencies and which ECS components should be present on entities that use this prefab. It also inspects the referenced render meshes to determine whether color-related components (PseudoRandomSeed, MeshColor) are required.
Fields
public NetLaneMeshInfo[] m_Meshes
Array of mesh descriptors used by this lane prefab. Each NetLaneMeshInfo contains a reference to a RenderPrefab (m_Mesh) and other mesh-specific parameters. The prefab uses this array when reporting dependencies and when checking whether meshes require color-related components.
Properties
- (none declared)
This class does not declare properties of its own; it inherits whatever properties exist on its base class NetLanePrefab.
Constructors
public NetLaneGeometryPrefab()
Default constructor (compiler-generated). No custom construction logic is declared in this class.
Methods
-
public override void GetDependencies(System.Collections.Generic.List<PrefabBase> prefabs)
Adds any Prefab dependencies from the m_Meshes array to the provided list. Calls base.GetDependencies(prefabs) first, then iterates m_Meshes and adds each m_Mesh (RenderPrefab) reference to prefabs. Use this so the prefab system knows to load referenced mesh prefabs before instantiating this prefab. -
public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Declares component types that must exist on any entity created from this prefab. Calls the base implementation, then adds: - ComponentType.ReadWrite
() -
ComponentType.ReadWrite
() -
public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Declares additional ECS components required for the archetype (entity layout) produced by this prefab. Behavior: - Calls base.GetArchetypeComponents(components).
- If ComponentType.ReadWrite
() is present in components, returns early (master lanes do not get lane geometry). - Otherwise adds:
- ComponentType.ReadWrite
() - ComponentType.ReadWrite
() - ComponentType.ReadWrite
()
- ComponentType.ReadWrite
- Inspects m_Meshes (if not null) and sets a flag if any referenced RenderPrefab has ColorProperties. If that flag is true, also adds:
- ComponentType.ReadWrite
() - ComponentType.ReadWrite
() This ensures color-related components are only added when one or more referenced render meshes require them.
- ComponentType.ReadWrite
Usage Example
// Example: reporting dependencies so the prefab loader can include referenced meshes
NetLaneGeometryPrefab lanePrefab = /* obtain prefab instance from editor or factory */;
lanePrefab.m_Meshes = new NetLaneMeshInfo[] {
new NetLaneMeshInfo { m_Mesh = someRenderPrefabA },
new NetLaneMeshInfo { m_Mesh = someRenderPrefabB }
};
var deps = new List<PrefabBase>();
lanePrefab.GetDependencies(deps); // deps will contain someRenderPrefabA and someRenderPrefabB
// Example: when building archetype/component lists, the prefab will add geometry and culling components.
// If any referenced RenderPrefab.Has<ColorProperties>() is true, PseudoRandomSeed and MeshColor are also added.
{{ Additional notes: - The prefab is decorated with [ComponentMenu("Net/Lane/", new Type[] { })], placing it in the editor's component menu under "Net/Lane/". - The class relies on several engine types: NetLaneMeshInfo, RenderPrefab, NetLaneGeometryData, SubMesh, MasterLane, LaneGeometry, CullingInfo, MeshBatch, PseudoRandomSeed, MeshColor. These types come from the game's rendering and ECS systems. - The GetArchetypeComponents early-return on MasterLane prevents adding per-lane geometry components to master (aggregate) lane entities. }}