Skip to main content

MaterialSwapper

A class in Root.Township, the global namespace.

Swaps a set of renderers between their own materials and one swap material. Does nothing on a headless server.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private Material[] baseMaterialsOriginal material of each target.
private Material swapMaterialMaterial put on when swapped.
private bool swapOnStartWhether to swap when the object wakes.
private Renderer[] targetRenderersRenderers whose material is swapped.

Methods​

MemberWhat it is
void Swap(bool isSwapped)True puts the swap material on every target, false restores the originals.
2 private and internal methods
MemberWhat it is
private void Awake()Stores the original materials and swaps at once if swapOnStart is set.
private void IBuildRendererPostBake.PostBake()Build step that drops null renderers.