Hi i have an array of gameobjects (they are actually buttons). I want to check when ALL of these buttons are disabled (SetActive(false));
public void CheckCondition(int amount)
{
if (shipMax[amount] <= 0)
{
buttons[amount].SetActive(false);
}
else if (shipMax[amount] > 0)
{
buttons[amount].SetActive(true);
}
}
This is how they get disabled. Each button handles an int and when this int is 0 the button gets disabled.
I looked up here and there seemed to be many answers already to this problem so i tried this out:
void StartGame()
{
for(int i = 0; i < buttons.Length; i++)
{
if(buttons*.activeSelf == false)*
{
Debug.Log(“ready”);
break;
}
}
}
I have this foreach loop running in Update(). However whenever just ONE of the elements inside the array gets disabled it already prints “ready”. Its supposed to print “ready” when all of the elements in the arra are disabled.
Is it that im running in Update()? Do i need to call this loop somewhere else? Did i write something wrong?
Thanks