Dropdown with list of buttons instead of toggles

Hi, I’m trying to replicate the behaviour of a standard dropdown from the Unity UI but with a list of buttons instead of a list of toggles.

Here is what I want it to look like : http://gph.is/2zHDgdY

For the context: I’m trying to make an inventory system where each items are prefabs and have a different list of options. For example, the item “Wood” has Burn, Drop and Cancel, while the item “Berries” has Consume, Cook, Drop and Cancel.

Usually, the standard dropdown seems to use toggles because it assumes there would be a sort of “Submit” button, but I would like and effect to be triggered as soon as the user clicks a certain option. However, when I try to change the options elements to have a Button component instead of a Toggle component, I get the error “The dropdown template is not valid. The template must have a child GameObject with a Toggle component serving as the item.”.

Thanks

I don’t think you can use buttons unless you roll your own dropdown component.

However, you can simulate it pretty easy.

In the Template, disable the Item Checkmark’s Image componant, and replacing the Item Background image component’s sprite with your button sprite. If your button already has the text for the button in the sprite, you can also disable the Text component in Item Label.

Your code will still have to check for which toggle is on, but the look and feel should be that of a button.

You can also disable the Text component of Label and and Image component of Arrow in the base of the DropDown, and change the DropDown image component to a button image to be clicked to access the DropDown, instead of displaying the text of the selected drop down item.

I know it isn’t what you are looking for, but it is a quick easy way to get the appearance you want.

Hope this helps,
-Larry