void ClearCommonButtonBranchers() { GameObject[] branchers = GameObject.FindGameObjectsWithTag("ButtonBrancher"); foreach (GameObject brancher in branchers) { if (brancher.transform.parent == transform.parent) //checks to see if it is the same parent { ButtonBranch bb = brancher.GetComponent <ButtonBranch>(); for (int i = bb.buttons.Count - 1; i >= 0; i--) { Destroy(bb.buttons[i]); } bb.buttons.Clear(); } } }
void ClearCommonButtonBranch() { GameObject[] branchers = GameObject.FindGameObjectsWithTag("ButtonBranch"); foreach (GameObject branch in branchers) { // check if the parent of this branch is the same as the branch we are currently looking at if (branch.transform.parent == transform.parent) { //removes the branchers button to keep things tidy ButtonBranch bb = branch.GetComponent <ButtonBranch>(); for (int i = bb.buttons.Count - 1; i >= 0; i--) { Destroy(bb.buttons[i]); } bb.buttons.Clear(); } } }