Skip to main content

RopeBelt

A class in Root.Township, the global namespace.

Belt visual that draws a mechanical belt as a rope tube mesh and scrolls its texture as the belt turns. Client visuals.

Constructors​

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

Fields​

10 private and internal fields
MemberWhat it is
private static readonly int _Sampler_STShader id of _Sampler_ST, the texture scale and offset.
private float actualTextureLengthWhole number of texture repeats along the belt.
private MaterialPropertyBlock blockProperty block used to set the texture offset.
private bool isGeneratingMeshEditor button that was meant to build the mesh.
private float lengthBacking field for Length.
private Mesh meshThe tube mesh being built.
private Renderer rendererThe belt's renderer.
private float ropeRadiusRadius of the rope tube.
private int ropeSidesNumber of sides around the tube.
private float textureLengthBelt length covered by one texture repeat.

Properties​

MemberWhat it is
float Length { get; }Length of the belt path, saved when the mesh was made.

Methods​

MemberWhat it is
override void DrawConnections()Scrolls the texture offset by the belt's rotation each draw.
protected override void Awake()Gets the renderer and works out how many texture repeats fit the stored length.
3 private and internal methods
MemberWhat it is
private float AddRings(List<float> lengths, List<Vector3> vertices, List<Vector3> normals, Vector3 previous2, Vector3 previous, Vector3 point, Vector3 face)Adds one ring of vertices and normals around a point on the belt path and returns that segment's length.
private void CreateMesh()Builds the tube mesh along the belt's points and stores its length. Not called anywhere in this build.
private void OnValidate()Editor: resets the isGeneratingMesh toggle. It no longer builds the mesh.

Used in​

Members of other types that take, return or hold a RopeBelt: