Making a previously selected UI button interactable again

Hey everyone,
In my game I have a list (scroll view) filled with buttons. Each button represents a unit that you can pick for a battle. Once the unit has been selected, the unit’s scriptable object is assigned to the corresponding slot, the mesh is instantiated and the button that was selected is set to be non interactable. Everything here works fine, however, when I re-open the menu for that slot, if I now want to replace that unit with a new one, the previous units button is still disabled, even after the slot has been successfully replaced. I have tried a “previous button” variable, however this was not successful. Keep in mind that each slot shares the same menu/list of fighters, selected buttons on other slots must be non interactable for any other slot also. I need a way to bring back interactability for a previously selected button when its slot has been replaced. Any help would be appreciated ! thank you :slight_smile:

You need to reset the “intractable” state of the button. You can do it with code:
Easiest solution would be to:

-Have a class that has a list of "Button"s exposed to the inspector.

public List<Button> buttons = new List<Button>();

-Apply all your buttons to that list in the inspector.

-Change every single button’s interactable state in OnEnable:

void OnEnable() { foreach(var button in buttons) { button.interactable = true; } }

This will reset the intractable state of all your buttons.
Note this is not the most optimized solution, It would be best to only reset the button that needs resetting.