private static void colorRecursive( RectTransform rectTransform, Color toColor )
{
if(rectTransform.childCount>0){
foreach (RectTransform child in rectTransform) {
UnityEngine.UI.MaskableGraphic uiImage = child.GetComponent<UnityEngine.UI.Image>();
if (uiImage != null) {
uiImage.color = toColor;
} else {
uiImage = child.GetComponent<UnityEngine.UI.RawImage>();
if (uiImage != null)
uiImage.color = toColor;
}
colorRecursive(child, toColor);
}
}
}