public class MultiGraphicSelectable : Selectable
{
[SerializeField] private List<GraphicInfo> targets;
protected override void DoStateTransition(SelectionState state, bool instant)
{
base.DoStateTransition(state, instant);
foreach (GraphicInfo target in targets)
{
if (target.graphic == null)
continue;
Color color = state switch
{
SelectionState.Disabled => target.colorBlock.disabledColor,
SelectionState.Highlighted => target.colorBlock.highlightedColor,
SelectionState.Normal => target.colorBlock.normalColor,
SelectionState.Pressed => target.colorBlock.pressedColor,
SelectionState.Selected => target.colorBlock.selectedColor
} * target.colorBlock.colorMultiplier;
target.graphic.CrossFadeColor(color, instant ? 0 : target.colorBlock.fadeDuration, true, true);
}
}
[Serializable]
public class GraphicInfo
{
public Graphic graphic;
public ColorBlock colorBlock;
}
}