Skip to main content

RendererMaterializerHandler

A class in Root.Township, the global namespace.

Helper that fades a set of renderers in or out with a dissolve shader, then puts the original materials back. Used by RendererMaterializer, DockedDissolver and StewManager; client visuals.

Constructors​

MemberWhat it is
RendererMaterializerHandler(Shader shader, Texture dissolveTexture)Creates a RendererMaterializerHandler from shader and dissolveTexture.

Fields​

12 private and internal fields
MemberWhat it is
private List<Renderer> allRenderersThe renderers being animated.
private static readonly int ColorShaderVariableShader id of _Color.
private MonoBehaviour coroutineBehaviourBehaviour the animation coroutines run on.
private static readonly int DissolveShaderVariableShader id of _Dissolve, the dissolve noise texture.
private static readonly int EmissionColorShaderVariableShader id of _EmissionColor.
private static readonly int EmissionShaderVariableShader id of _Emission.
private static readonly int MainTextureShader id of _MainTex.
private AltaCoroutine materializationAnimationThe running materialise coroutine, so dematerialise can stop it.
private List<Material> materialsToAnimateDissolve materials made so far. It is never cleared, so it grows with each run.
private Dictionary<Renderer, Material> originalMaterialsEach renderer's material from before the first dissolve.
private static Type particleSystemRendererCached ParticleSystemRenderer type, skipped by SetTargetObject.
private static readonly int ProgressShaderVariableShader id of _Progress, the dissolve amount.

Properties​

MemberWhat it is
Texture DissolveTexture { get; set; }Noise texture set on every dissolve material.
Shader Shader { get; set; }The dissolve shader used for the temporary materials.

Methods​

MemberWhat it is
void DemateralizeRenderers(float duration, Action animationFinishedCallback = null)Stops any materialise run, then glows the renderers up and dissolves them away over duration.
void MaterializeRenderers(float duration, Action animationFinishedCallback = null)Hides the renderers, then dissolves them in over duration and calls the callback when done.
void SetTargetObject(Transform rendererParent, MonoBehaviour coroutineBehaviour)Targets every renderer under a transform except particle renderers, and sets the behaviour that runs the coroutines.
void SetTargets(IEnumerable<Renderer> renderers, MonoBehaviour coroutineBehaviour)Targets the given renderers and sets the behaviour that runs the coroutines.
8 private and internal methods
MemberWhat it is
private void ChangeAllMaterialsToDissolve()Gives each renderer a new dissolve material copying its texture or colour, and remembers the original. Multi-material renderers end up with one material.
private IEnumerator DematerializeAnimation(float duration, Action animationFinishedCallback) (iterator)Coroutine: raises emission, swaps to dissolve materials, then runs progress 0 to 1, then calls the callback.
private void InstanceAllMaterials()Gives each renderer its own material instance so emission changes don't touch shared materials.
private IEnumerator MaterializeAnimation(float duration, Action animationFinishedCallback) (iterator)Coroutine: waits two frames, dissolves in from 1 to 0, fades emission out, restores originals, then calls the callback.
private void ResetAllMaterials()Puts each renderer's original material back.
private void ResetAllMaterialsInstanced()Gives each renderer a fresh copy of its original material, so emission can fade without changing the shared one.
private void SetMaterialsEmission(float emission)Sets emission colour (and _Emission if present) on every renderer's material.
private void SetMaterialsProgress(float progress)Sets _Progress on every dissolve material.

Used in​

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