Change color of all buttons listed in array

Hi,
I am trying to change the colour of all buttons listed in an array, however I can’t seem to figure it out.

public GameObject buttonArray;

void Update()
{

buttonArray = GameObject.FindGameObjectsWithTag(“buttonBall”);

for (int i = 25; i < buttonArray.Length; i++) {

GetComponents().color = new Color(255f, 0f, 0f, .6f);
>}}
This does not throw up any errors but the colour component of the buttons tagged “buttonBall” does not change.
Can anybody see where I am going wrong? any help would be appreciated.
Thanks

This changes the actual buttons’ colors (the normal color, not highlighted, pressed or disabled).

using System.Linq;

//attention: GameObject.Find... are really slow functions and should be called as seldom as possible
Button[] buttonArray = GameObject.FindGameObjectsWithTag("buttonBall").Select(obj => obj.GetComponent<Button>()).ToArray();

foreach(Button button in buttonArray) {
    button.colors.normalColor = new Color(255, 0, 0, 0.6f);
}

If you want to change the color of the image component, then you have to edit the code accordingly.

using System.Linq;

//attention: GameObject.Find... are really slow functions and should be called as seldom as possible
Image[] buttonArray = GameObject.FindGameObjectsWithTag("buttonBall").Select(obj => obj.GetComponent<Image>()).ToArray();

foreach(Image img in buttonArray) {
    img.color = new Color(255, 0, 0, 0.6f);
}

If you don’t want to use Linq, you can do this instead:

GameObject[] objs = GameObject.FindGameObjectsWithTag("buttonBall");

foreach(gameObject go in objs) {
    go.GetComponent<Image>().color = new Color(255, 0, 0, 0.6f);
}

All of the above assume, that every object that is tagged ‘buttonBall’ has a Button or Image Component. If that is not the case:

GameObject[] objs = GameObject.FindGameObjectsWithTag("buttonBall");

foreach(gameObject go in objs) {
    Image img = go.GetComponent<Image>()
    if (img != null) img.color = new Color(255, 0, 0, 0.6f);
}

Why does your for loop start at 25? That looks problematic. If you’re really trying to change all items in the array, that should be:

for (int i = 0; ...

Here this should fix the problem.

public GameObject[] buttonArray;

void Update()
{
     buttonArray = GameObject.FindGameObjectsWithTag("buttonBall");

     for (int i = 1; i < buttonArray.Length; i++) 
     {
         buttonArray*.color = new Color(255f, 0f, 0f, .6f);*

}
}