public void DeletePictures() { int x = 0; foreach (Transform child in imagesPanel.transform) { if ((child.gameObject.GetComponent <Toggle>().isOn)) { // Call for deletion of any word pictures using the word and current integer Debug.Log("VWREMOVE: TOGGLE ON! THE INDICE TO DELETE IS :" + x); indicesToDelete.Add(x); Destroy(child.gameObject); } x += 1; if (x >= imagesPanel.transform.childCount) { break; } } if (indicesToDelete.Count > 0) { Debug.Log("indicesToDelete count is " + indicesToDelete.Count); controller.DeleteWordImages(indicesToDelete, controller.IsEditSettings ? wordText.GetComponent <Text>().text : wordFieldText.text); imageDeleted = true; saveButton.interactable = true; } saveButton.interactable = true; }