Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So I've got a load menu using Unity's new UI system, basically just a list of save games you can select with a mouse click along with a couple of buttons at the bottom to delete or load the selected game file.

I've been disabling the Load Game and Delete Game buttons using the interactable attribute whenever a saved game item in the list is deselected:

deleteButton_LoadPanel.GetComponent<Button>().interactable = false;     
loadButton_LoadPanel.GetComponent<Button>().interactable = false;

This disables the buttons fine, but when I click on a saved game and then click a button, the deselect event for each save file is triggered BEFORE the onclick event for each button. This is no good.

If I have no deselection event for each individual save file I can click on each save file and then click the load or delete buttons and every thing works fine, but the buttons never get disabled which is not ideal.

My question is: How can I disable the buttons when an item is deselected, but still trigger the onclick event when they are selected? Are there any workarounds to this?

enter image description here

share|improve this question

1 Answer 1

Sounds like what you're looking for is more along the lines of a Toggle Group

A Toggle Group is not a visible UI control but rather a way to modify the behavior of a set of Toggles. Toggles that belong to the same group are constrained so that only one of them can switched on at a time - pressing one of them to switch it on automatically switches the others off.

This also requires that you use Toggles instead of Buttons.

The styling of the toggle can be made to match that of your buttons now.

share|improve this answer
    
@mir Is this not what you're looking for? You've unaccepted this as the answer. –  Byte56 May 31 at 23:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.