Material Changer

Overview

Allows to change materials on a mesh or meshes on a same gameObject

It uses a List of <Material Items> to set 1 or more material changes to 1 or more meshes at the same time.

You can create any new Material Item by clicking on the Plus(+) button of the list.

Properties

Shows/Hide the selected Material Item properties.

When you select a Material Item on the list you will have the (Index), the Name, and Button with the Current Material used on the Mesh of that Material Item

Change Hide Meshes [CH]

It will change the material even if the Mesh renderer is Hidden

Random [R]

It will set a random Material on Start on every Material Item. Useful to create random variations

Change Material Button

When you click the Change Material Button it will cycle between all the Materials on the Material Item.This only work on the Editor. For Game purposes use Public methods.

Material Item

The Material Item is a struct class that holds all the Parameters and properties needed to change the material on a single mesh and its LODs

Mesh

Mesh Renderer used to change the materials.

ID

Sometimes a Mesh can have multiple materials assigned. They can me Identified by a Material ID

Material List

All the Materials a single mesh can cycle trough.

LODs

If a Mesh has LODs you set them here. It will change the same material to multiple to the meshes on the LOD List.

When enabled, a material Item will be Locked and it will only change if the Master Material Item change. The Master property is the Index of the Material Item.

E.g. On the Elemental Dragon the Wings will change automatically to another material when the Body Material Changes

On Material Changed Event

Is invoked when a Material Item changes a material

Public Methods

void Randomize()

Randomize all the Material Items on the Material Changer Component

void SetMaterial(int index, bool next = true)

Changed to the Next/Before Material on the Material Item using its Index on the List

index - Material Item Index on the list

next - if True it will change to the next material, if False it will change to the last material

void SetMaterial(string name, int index)

Changed to the Material on the Material Item using its name and the material Index

name: Material Item name

index: index of the Material inside the Material Item

void SetMaterial(string name, bool next = true)

Changed to the Next/Before Material on the Material Item using its name

name Material Item name

next if True it will change to the next material, if False it will change to the last material

void SetMaterial(int index, int nextIndex)

Changed to a specific Material on the Material Item using its Index on the List.

index Material Item Index on the List

nextIndexMaterial Index on the Material Item

void NextMaterialItem(int index)

Changed to the next Material on the Material Item using its Index on the List.

index Material Item Index on the List

void NextMaterialItem(int index)

Changed to the next Material on the Material Item using its Index on the List.

indexMaterial Item Index on the List

void NextMaterialItem(string name)

Changed to the next Material on the Material Item using its Index on the List.

nameMaterial Item name on the List

int CurrentMaterialIndex(string name)

Returns the Current Index of a Material used on a Material Item

nameMaterial Item name on the List

Last updated