Game.Prefabs.NetTerrainPiece
Assembly:
Assembly-CSharp (typical for game/mod scripts — adjust if the class is in a different assembly)
Namespace:
Game.Prefabs
Type:
public class
Base:
ComponentBase
Summary:
A prefab component used by net (road/rail/etc.) pieces to carry terrain-related offset data. It exposes width and clip height offsets (float2) and per-corner min/max height offsets (float3). When creating an entity prefab, this component declares that the prefab requires the NetTerrainData ECS component via GetPrefabComponents.
Fields
-
public Unity.Mathematics.float2 m_WidthOffset
X/Y offsets affecting the piece width; typically used to shift mesh vertices or sampling positions laterally across the piece. -
public Unity.Mathematics.float2 m_ClipHeightOffset
X/Y offsets used to adjust clipping or sampling heights along the piece (e.g., to modify where terrain clipping occurs). -
public Unity.Mathematics.float3 m_MinHeightOffset
Per-corner minimum height offsets (3-component vector used by the system to adjust or clamp terrain heights). -
public Unity.Mathematics.float3 m_MaxHeightOffset
Per-corner maximum height offsets (3-component vector used by the system to adjust or clamp terrain heights).
Properties
- None (this class does not declare properties).
Constructors
public NetTerrainPiece()
Default parameterless constructor (inherited behavior from ComponentBase). Instances are typically created/initialized by Unity or the editor when the prefab is set up.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds runtime/component requirements for the prefab to the provided set. Implementation addsComponentType.ReadWrite<NetTerrainData>()
, indicating that entities created from this prefab should include a NetTerrainData component. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Empty override in this class — reserved for adding additional ECS archetype components if needed by derived classes or future changes.
Additional info:
- The class is decorated with [ComponentMenu("Net/", new Type[] { typeof(NetPiecePrefab) })]
, which places it under the "Net/" menu in the component/prefab creation UI and links it to NetPiecePrefab usage in editor tooling.
- Uses types from Unity.Mathematics (float2, float3) and Unity.Entities (ComponentType).
Usage Example
// Example: how the prefab declares its ECS component dependency
NetTerrainPiece piece = /* obtain from prefab or inspector */;
var components = new HashSet<ComponentType>();
piece.GetPrefabComponents(components);
// components now contains ComponentType.ReadWrite<NetTerrainData>()
// The game/mod code that converts the prefab into an entity archetype
// should include the NetTerrainData component when creating entities.