Changing the names of a list of Buttons all at once?

Basically I want to have a list of button objects, then run through the whole list and change their names dynamically.

public Text[] buttonTexts; //assign in inspector public void ChangeButtonNames(string toName) { foreach (var button in buttonTexts) { button.text = toName; } }

1 Answer

1

public Text buttonTexts; //assign in inspector

public void ChangeButtonNames(string toName) {
    foreach (var button in buttonTexts) {
        button.text = toName;
    }
}

This is pretty basic.