1using System.Collections.Generic;
27 [ColorUsage(
false,
true)]
59 [Header(
"Body Renderers (color changes)")]
77 private int _currentIndex;
78 private MaterialPropertyBlock _mpb;
84 void Awake() => _mpb =
new MaterialPropertyBlock();
98 _currentIndex = (_currentIndex + 1) %
variants.Count;
107 Apply(_currentIndex);
115 if (index < 0 || index >=
variants.Count)
return;
116 _currentIndex = index;
139 void Apply(
int index)
144 if (r ==
null)
continue;
145 r.GetPropertyBlock(_mpb);
146 _mpb.SetColor(
"_BaseColor", v.baseColor);
147 _mpb.SetFloat(
"_Metallic", v.metallic);
148 _mpb.SetFloat(
"_Smoothness", v.smoothness);
149 _mpb.SetColor(
"_EmissiveColor", v.emissiveColor);
150 r.SetPropertyBlock(_mpb);
Applies ProductVariant presets to a set of Renderers using MaterialPropertyBlock.
ProductVariant CurrentVariant
The currently active ProductVariant, or null if the list is empty.
void NextVariant()
Advances to the next variant, wrapping around the list.
void PreviousVariant()
Steps back to the previous variant, wrapping around the list.
System.Action< int, ProductVariant > OnVariantChanged
Fired after a variant change with (newIndex, newVariant).
string CurrentVariantName
Display name of the active variant (empty string if none).
List< Renderer > bodyRenderers
Renderers whose material properties will be overridden.
void SetVariantIndex(int index)
Jumps directly to a variant by index.
int VariantCount
Total number of registered variants.
int CurrentIndex
Zero-based index of the active variant.
List< ProductVariant > variants
Ordered list of PBR colour presets available in the visualizer.
Serialisable PBR colour preset applied through MaterialPropertyBlock.
float metallic
Metallic value in [0, 1] mapped to _Metallic.
string variantName
Human-readable name displayed in the UI (e.g. "Ocean Blue").
Color emissiveColor
HDR emissive colour mapped to _EmissiveColor.
float smoothness
Smoothness (gloss) value in [0, 1] mapped to _Smoothness.
Color baseColor
Albedo colour mapped to the HDRP _BaseColor property.