Skip to main content

TemperatureToMaterial

A class in Root.Township, Alta.Heat.

Client: makes metal glow with heat by setting the _ForcedTemperature shader property on its renderers from a heat point's temperature. Does nothing on a headless server.

Constructors​

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

Fields​

6 private and internal fields
MemberWhat it is
private static readonly int _ForcedTemperatureShader property ID for _ForcedTemperature.
private HeatPoint heatPointThe heat point whose temperature drives the glow.
private static Logger loggerClass logger, used when a renderer in the list is null.
private MaterialPropertyBlock propsProperty block reused to set the shader value.
private Renderer[] targetRenderersRenderers that get the temperature value.
private AnimationCurve temperatureToValueCurve from temperature to the 0 to 1 shader value. Default runs from 23 to 1200 degrees.

Methods​

MemberWhat it is
void OnValidate()Editor: fills in the heat point and, if empty, the renderers that use the Township Tale/MetalNonForging shader.
3 private and internal methods
MemberWhat it is
private void Awake()Off headless, creates the property block and subscribes to the heat point's Changed event.
private void IBuildRendererPostBake.PostBake()Build step: strips null entries from the renderer list.
private void UpdateValue(HeatPoint heatPoint)Maps the heat point's temperature through the curve and applies it to every target renderer.