Skip to main content

LevelEffectSize

A class in Root.Township, Alta.StatSystem.

Visual for a levelled stat effect: copies some mesh renderers with an overlay material and sets a shader value from the level. Client only. Nothing in code calls UpdateLevel, so it is probably wired up through a Unity event.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private string affectingParameterName of the shader float the level drives.
private MeshRenderer[] animatingRenderersThe overlay copies of the target renderers, created on first use.
private AnimationCurve levelToValueCurve from level to the shader value.
private Material materialThe overlay material; a copy of it is used.
private int parameterIDShader property ID of affectingParameter.
private LODGroup referenceLODGroupLOD group used at build time to keep only LOD 0 renderers.
private MeshRenderer[] targetRenderersMesh renderers that get an overlay copy.
private Material uniqueMaterialThis instance's copy of material.

Methods​

MemberWhat it is
void UpdateLevel(int level)Client: above level 0, creates the overlay copies if needed, shows them and sets the shader value from the curve. At 0 it hides them.
4 private and internal methods
MemberWhat it is
private void Awake()Client: looks up the shader property ID for affectingParameter.
private MeshRenderer CopyRenderer(MeshRenderer original)Makes a child object with the same mesh as a target renderer, drawn with the unique overlay material.
private void OnDestroy()Cleans up the unique material.
private void IBuildRendererPostBake.PostBake()Build step: drops target renderers that are null or not in LOD 0 of the reference LOD group.