void checkGoodTilesPressed() { foreach (GameObject obj in goodTiles) { //Checks each tile in the list if they are pressed. When pressed during the program, they are added to the list "goodPressedTiles" CubesChild tempCube = obj.GetComponentInChildren <CubesChild>(); bool pressedFromChild = tempCube.pressed; if (pressedFromChild && !goodPressedTiles.Contains(obj)) { goodPressedTiles.Add(obj); } } }
void Start() { //Loops through all tiles foreach (GameObject obj in tileList) { //Checks each tile if they are supposed to be pressed, if they are, they are added to a list called "goodTiles" CubesChild tempCube = obj.GetComponentInChildren <CubesChild>(); bool goodFromChild = tempCube.good; if (goodFromChild) { goodTiles.Add(obj); } } }