Unity: State Based Buttons
When I first started using Unity, I fell in love with the way that you could just make a button. No fuss, no issue, just right-click->UI->Button and you’re done. What more could you need? All a button does is get clicked right?
Let’s take a moment and list out the 6 things a button can possibly do
- A button can be clicked
- 2. A button can have a color, hover color/effect
- A button can be toggled and have more than one state
- A button could have text or an icon
- A button’s text, icon, color, or shape can change with its state
- A button can have a value
The Unity button can handle 4.5 out of 6 of those features. The 1 and a half features that it can’t handle is being able to be toggled and the ability for it to have a baked in value.
So you may be confused about the second part. It is true that a button can be set to a function which has a baked in value so you can get away with this. But take a moment and consider how you would make that system work when you want the value to change between states.