I have an array of booleans in C#, and after a specific input I would like to loop through and set all of these booleans to false. But I am getting the following error with the loop code:
Cannot assign to buttonBoolean' because it is a
foreach iteration variable’
And here is the code:
public bool[] inputBool;
foreach (bool buttonBoolean in inputBool) {
buttonBoolean = false;
}
The booleans in the array all come from the one script which is attached to one gameobject in the scene. I’ve used a loop similar to the above to for example turn off/deactivate all the gameobjects in an array, so I’m not sure why it isn’t working for turning off all the booleans in an array.