Thanks thats really helpful.
I'm not able to use
skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial;
as my character has a lot of different skins and grabbing the primary is the first skin. How should I get the current material that is being used by the Mesh Renderer or is it ok to use
meshRenderer.sharedMaterial
.
var meshRenderer = m_character.skeleton.GetComponent<MeshRenderer>();
var originalMaterial = meshRenderer.sharedMaterial;
m_overrideMaterial = new Material(originalMaterial);
m_overrideMaterial.name = m_overrideMaterial.name + "_override";
m_overrideMaterial.EnableKeyword("_COLOR_ADJUST");
m_overrideMaterial.SetFloat("_Saturation", m_saturation);
m_overrideMaterial.SetFloat("_Brightness", m_brightness);
m_character.skeleton.CustomMaterialOverride[originalMaterial] = m_overrideMaterial;