Skip to main content

SeasonalLeaves

A class in Root.Township, the global namespace.

Cycles a leaf material's colour, fade and randomness through a gradient and curves over time, with the cycle position synced to joining players.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private AnimationCurve fadeTimeCurve for the _FadeTime shader value over the cycle.
private Gradient gradientLeaf colour over the cycle.
private Material materialThe leaf material to change. Shared, so every user of it changes.
private AnimationCurve randomnessCurve for the _Randomness shader value over the cycle.
private float randomSeedSeed sent to the shader as _Seed, new each cycle.
private float speedCycles per second. Default 0.1.
private MethodSync syncMethod sync for time and seed.
private float timePosition in the cycle from 0 to 1.

Methods​

MemberWhat it is
override void Initialize()Picks a random seed and creates the sync.
override void OnConnected(Player player)Sends the current time and seed to a joining player.
4 private and internal methods
MemberWhat it is
private void OnValidate()Updates the material in the editor.
private void Sync(IPlayer player, Stream stream)Syncs time and randomSeed, and updates the material when reading.
private void Update()Advances time by speed; when it wraps past 1, picks a new seed, sends it to the chunks and sets it on the material.
private void UpdateMaterial()Sets the material's _Color, _FadeTime and _Randomness from the gradient and curves at the current time.