How do I set category for buttons and do something like this?

Hello,

In the prototype, player can select several options to adjust difficulty of the game. These options are divided into a few categories. For example:

Category 1: Race
Opt 1: Human + 10 difficulty
Opt 2: Orc + 30 difficulty
Opt 3: Elf + 5 difficulty
Opt 4: Dwarf + 15 difficulty

Category 2:
Opt 1: + 7 difficulty
Opt 2: + 14 difficulty

When player chooses an option, it adds up the Difficulty Gauge (updated in real time). But when player chooses another option in the same category, it subtracts the previous option and then adds the new one.

This is what I tried and failed:

  • I added a new script to buttons to store their category as string
  • I don’t know how to use that in OnClick() in a button
  • I have no idea how to go forward

I’m still quite new to programming. Thank you for any suggestions.

Screenshot of the prototype:

I’d recommend you use toggles and toggle groups

https://docs.unity3d.com/Manual/script-Toggle.html
https://docs.unity3d.com/Manual/script-ToggleGroup.html

2 Likes