private static void alphaRecursive( RectTransform rectTransform, float val, int recursiveLevel = 0)
{
if(rectTransform.childCount>0){
foreach (RectTransform child in rectTransform) {
UnityEngine.UI.MaskableGraphic uiImage = child.GetComponent<UnityEngine.UI.Image>();
if (uiImage != null) {
Color c = uiImage.color; c.a = val; uiImage.color = c;
} else {
uiImage = child.GetComponent<UnityEngine.UI.RawImage>();
if (uiImage != null) {
Color c = uiImage.color; c.a = val; uiImage.color = c;
}
}
alphaRecursive(child, val, recursiveLevel + 1);
}
}
}