void DeleteParts() { if (attachingMode == true && Input.GetKeyDown(KeyCode.Delete)) { Transform[] allChildren = focusedPart.GetComponentsInChildren <Transform>(); foreach (Transform child in allChildren) { spaceShip.shipParts.Remove(child.GetComponent <ShipPart>()); } Destroy(focusedPart.gameObject); attachingMode = false; if (spaceShip.shipParts.Count == 0) { isFirstPartSelection = true; inputField.GetComponent <InputField>().text = ""; inputField.GetComponent <InputField>().interactable = false; } } }