unity-game-enginebuttonhighlight

How to Get UI button to Stay in a Pressed State in Unity 3D


In Unity 3D, when you select a button, it will stay pressed until you click outside the button and basically goes back to its Normal Color. The problem is, I want the button to stay pressed (color-wise) when I click outside the button or scene. Does anyone know how to keep a button pressed or "selected" after clicking it?


Solution

  • You can use Unity UI Toggle (as said by Muhammad). Change the design to remove the checkmark and make it looking like a button. With this component you have the state 'isOn' that you can use and change the color when selected for example.