Skip to main content

SplineCylinder

A class in Root.Township, Alta.Bezier.

Builds a tube mesh along a BezierSpline (such as a rope or pipe) and gives it a matching MeshCollider. Also runs on headless servers, so the collider exists there.

Constructors​

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

Fields​

12 private and internal fields
MemberWhat it is
private int edgesNumber of sides around the tube; 6 by default.
private MeshFilter filterThe MeshFilter the mesh is written to.
private bool isUsingSmartSegmentCountWhen on, each curve gets more segments the more it bends, instead of a fixed segments count.
private float normalOffsetSideways offset of the tube from the spline.
private Vector3 normalUpUp direction used to work out the tube's sideways axes.
private AnimationCurve radiusTube radius along the spline, from 0 (start) to 1 (end).
private int segmentsNumber of segments along the spline when smart segments are off. Overwritten with the total when they are on.
private float smartSegmentMinimumFewest segments per curve with smart segments.
private float smartSegmentRatioMultiplierHow many extra segments a curve gets per unit of bend (path length over straight distance).
private float uvStretchLength of spline per unit of texture V; higher stretches the texture.
private float yOffsetFixed upward offset of the whole tube.
private AnimationCurve yPointOffsetUpward offset along the spline, from 0 (start) to 1 (end).

Properties​

MemberWhat it is
protected override bool IsHeadlessOnly { get; }False, so the tube is generated on headless servers too (the base class skips them when this is true).

Methods​

MemberWhat it is
protected override void GenerateInternal()Samples the spline, builds a ring of vertices at each point and writes the tube mesh, then adds the collider.
1 private and internal method
MemberWhat it is
private void AddCollider(Mesh mesh)Sets the mesh on the object's MeshCollider, adding one if missing.