Skip to main content

MaterialToggler

A class in Root.Township, the global namespace.

Debug tool: Shift+M swaps materials on spawned objects (those using an aFrom material) to to, then puts them back in two timed steps. Probably for checking which objects use which materials.

Constructors​

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

Fields​

MemberWhat it is
static MaterialToggler instanceThe first MaterialToggler.
9 private and internal fields
MemberWhat it is
private List<Material> aFromMaterials that get swapped to to.
private List<Material> bFromMaterials that stay swapped after the second step.
private MeshRenderer[] foundRenderersRenderers found under the spawned objects folder by ChangeA.
private IKeyBoardTriggerHandler keyboardHandlerHandle of the M key registration.
private List<MaterialToggler.RendererToMaterial> renderersToToggleSwapped renderers and their original materials.
private AltaCoroutine runningThe running ProceedChanges coroutine.
private Texture[] texturesTextures UpdateMipMapBias changes.
private Material toMaterial put on during the swap.
private float waitDurationSeconds between steps.

Methods​

MemberWhat it is
void ChangeA()Puts to on every spawned renderer whose material is in aFrom, remembering the originals.
void ChangeB()Restores the swapped renderers whose original material is not in bFrom.
void Clear()Restores every remaining swapped renderer.
IEnumerator ProceedChanges() (iterator)Coroutine running the A swap, the B restore and the final restore, waitDuration seconds apart.
void UpdateMipMapBias(float bias)Sets the mip map bias of every texture in textures.
3 private and internal methods
MemberWhat it is
private void Awake()Keeps the first instance (destroys duplicates) and registers the M key.
private void CheckKey(Key key)On M with left Shift held, starts ProceedChanges unless it is already running.
private void OnDestroy()Unregisters the M key.