how to check all elements in array

How to check one by one element is true in array.
I collected part of toys and i have fully repaired toy.

I want check part of toys is false and one by one bool is true of 1/3.

And if all 3/3 is true fullyrepaired is active.

 for(int i = 0; i < buttons.Length; i++)
         {
             if(buttons*.activeSelf == false)*

{
Debug.Log(“ready”);
break;
}
}
^^ My examble code from internet.
for (int i = 0; i < isRepaired.Length; i++)
{
if (partOfToys*.activeSelf)*
{

isRepaired[index] = true;
print(i);

}

index++;
}

repairedIsReady(); // Check if all is true and active full Toy :slight_smile: << This working right.

}
My own code with error. I collected 1/3 toy all 3/3 is true. WHY???
Can anyone help me?

Hello, why you duplicate your index ?
Var index and i does the same thing !

     for (int i = 0; i < isRepaired.Length; i++)
         {
             if (partOfToys*.activeSelf)*

{

isRepaired[index] = true;
print(i);

}

index++;
}

repairedIsReady(); // Check if all is true and active full Toy :slight_smile: << This working right.

}
Try this :wink:
Raph

for checking all booleans in an array use linq:
using System.Linq;

if (myarray.All(x => x)){
//do something }

public void UseToyPart(GameObject toy)
{

        var toys = Random.Range(0, partOfToys.Count);

       
            for (int i = 0; i < isRepaired.Length;)
            {
                //if (isRepaired *== false)*

if (partOfToys*.activeSelf)*
{

isRepaired = true;

}

i++;
}

repairedIsReady(); // Check if all is true and active full Toy :slight_smile: << This working right.

}

What i say in if Statement? @dan_wipf I want set one bool true if i collected one part of toys.
Only if i collected all parts repairedIsReady(): method happend.
Now it hapend if i collected first part.

This is so simple problem how i set one bool true if one part is collected?

This is infuriating. :smiley:

I try your code @dan_wipf.
but why iscollected not more +1? only 0 >> 1 but not 1 >>2 and 2>>3

see this link photo.