public bool HideAllObjects;
public GameObject ObjectsToHide;
void Update()
{
if (HideAllObjects)
{
ObjectsToHide[ObjectsToHide.Length].SetActive(false);
}
The length of an array is the number of elements, but element indexes start with zero.
The last element’s index is the array length minus one.
ObjectsToHide[ObjectsToHide.Length-1]