Skip to main content

SplineMesh

A class in Root.Township, Alta.Bezier.

Spline display that builds a strip mesh (a wall or fence-like profile) along its parent BezierSpline and gives it a matching MeshCollider. Generates on the server too.

Constructors​

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

Fields​

17 private and internal fields
MemberWhat it is
private MeshFilter filterThe MeshFilter that holds the generated mesh.
private float halfWidthBottomHalf the strip's width at its base.
private float halfWidthTopHalf the strip's width at its top.
private float heightHeight of the strip above the spline.
private bool isGeneratingBottomIf set, also builds the bottom faces.
private bool isUsingSmartSegmentCountIf set, the segment count per curve is worked out from how much it bends instead of using segments.
private float normalOffsetSideways offset of the strip from the spline.
private Vector3 normalUpUp direction used to build the strip's cross section.
private int segmentsNumber of segments along the whole spline; overwritten when smart segment count is on.
private float smartSegmentMinimumSmart segment count: minimum segments per curve.
private float smartSegmentRatioMultiplierSmart segment count: extra segments per unit of curve length over straight-line length.
private float uvBottomEndV coordinate for the bottom edge on one side.
private float uvBottomStartV coordinate for the bottom edge on the other side.
private float uvStretchWorld distance covered by one unit of U along the strip.
private float uvTopEndV coordinate for the top edge on one side.
private float uvTopStartV coordinate for the top edge on the other side.
private float yOffsetVertical offset of the whole strip along normalUp.

Properties​

MemberWhat it is
protected override bool IsHeadlessOnly { get; }Returns false, so this mesh is generated on a headless server as well (for its collider).

Methods​

MemberWhat it is
protected override void GenerateInternal()Samples the spline, builds the vertices, UVs and triangles of the strip and its end caps, then updates the collider.
1 private and internal method
MemberWhat it is
private void AddCollider(Mesh mesh)Adds a MeshCollider if missing and sets its mesh to the generated one.