My code is not working. here is my code and I will explain what it outputs
private void Update()
{
if (Input.GetKeyDown(KeyCode.Return))
{
for (int i = 0; i < yNum; i++)
{
for (int j = 0; j < xNum; j++)
{
for (int k = 0; k < zNum; k++)
{
if (row[i * (xNum * zNum) + j * zNum + k].GetComponent<Renderer>().material.color.Equals(userRow[i * (xNum * zNum) + j * zNum + k].GetComponent<Renderer>().material.color))
{
alltrue[i * (xNum * zNum) + j * zNum + k] = true;
}
else
{
alltrue[i * (xNum * zNum) + j * zNum + k] = false;
}
}
}
}
if (alltrue.ToList<bool>().All(b => b))
{
Debug.Log("Good");
b.LevelUp();
level++;
int buildSize = GameObject.FindGameObjectsWithTag("build").Length;
int displaySize = GameObject.FindGameObjectsWithTag("display").Length;
GameObject[] builds = GameObject.FindGameObjectsWithTag("build");
DestroyArray(builds);
GameObject[] displays = GameObject.FindGameObjectsWithTag("display");
DestroyArray(displays);
xNum++;
yNum++;
Debug.Log("build: " + buildSize + " || " + GameObject.FindGameObjectsWithTag("build").Length);
Debug.Log("display: " + displaySize + " || " + GameObject.FindGameObjectsWithTag("display").Length);
Generate();
}
else
{
Debug.Log("Not Good");
}
}
void DestroyArray(GameObject[] b)
{
foreach (GameObject k in b)
Destroy(k);
}
}
now as you can see I have many debug.logs. In this line
Debug.Log("build: " + buildSize + " || " + GameObject.FindGameObjectsWithTag(“build”).Length);
it logs:
12||12
it should log “12||0” because it was supposed to destroy all the objects in the array. Can somebody help me?