Skip to main content

CurveWall

A class in Root.Township, the global namespace.

Builds a wall mesh and matching MeshCollider along a Bezier spline of CurvePoints. Editor and level-design tool; it can be baked, after which the component removes itself and leaves the mesh.

Constructors​

MemberWhat it is
CurveWall()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

11 private and internal fields
MemberWhat it is
private MeshFilter filterCached MeshFilter holding the mesh.
private float halfWidthBottomHalf the wall's width at the base.
private float halfWidthTopHalf the wall's width at the top.
private float heightWall height along normalUp.
private bool isGeneratingBottomWhether to add faces under the wall.
private Vector3 normalUpUp direction used for height and side offsets.
private int segmentsSamples per spline segment.
private List<CurveWall.CurvePoint> splineNodesBacking field for SplineNodes.
private float uvStretchWorld length per UV unit along the wall.
private float uvTopEndUV V value at one top edge.
private float uvTopStartUV V value at the other top edge.

Properties​

MemberWhat it is
bool IsBaked { get; set; }True once baked; until then the mesh is flagged not to save into builds.
List<CurveWall.CurvePoint> SplineNodes { get; }The spline's nodes, for editor tools.

Methods​

MemberWhat it is
void CheckEmpty()Adds two default nodes 10 units apart if the spline has none.
Vector3 GetPosition(int index, float time)Meant to return a point on the spline segment index at time; the bounds check is inverted, so it returns the last node for most indices.
Mesh UpdateMesh()Samples the spline and builds a wall with a sloped top and end caps, then returns the mesh.
5 private and internal methods
MemberWhat it is
private void AddCollider(Mesh mesh)Adds a MeshCollider if missing and gives it the generated mesh.
private void Awake()Rebuilds the mesh unless running headless.
private void IBakeable.Bake()Builds the mesh, marks it baked and destroys this component.
private void CheckSetup()Caches the MeshFilter.
private void OnValidate()Rebuilds the mesh when inspector values change.