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.
- Listed in Global namespace: S
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
SeasonalLeaves() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private AnimationCurve fadeTime | Curve for the _FadeTime shader value over the cycle. |
private Gradient gradient | Leaf colour over the cycle. |
private Material material | The leaf material to change. Shared, so every user of it changes. |
private AnimationCurve randomness | Curve for the _Randomness shader value over the cycle. |
private float randomSeed | Seed sent to the shader as _Seed, new each cycle. |
private float speed | Cycles per second. Default 0.1. |
private MethodSync sync | Method sync for time and seed. |
private float time | Position in the cycle from 0 to 1. |
Methods
| Member | What 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
| Member | What 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. |