Search Issue Tracker
By Design
Votes
1
Found in
2020.3.16f1
2021.1.17f1
2021.2.0b7
2022.1.0a5
2023.1.0a1
2023.2.0a1
2023.3.0a3
6000.0.0b11
Issue ID
UUM-3438
Regression
Yes
Button doesn't appear as toggled/activated when using GUIStyle with GUI.skin.button.active.background
How to reproduce:
1. Open the attached project's Scene labeled "SampleScene"
2. In the Hierarchy, select the "ButtonsManager" GameObject
3. In the Inspector, click the custom button
Expected result: Button changes the background when clicked
Actual result: Button's background doesn't change when clicked
Reproducible with: 2019.3.0a3, 2019.4.29f1, 2020.3.16f1, 2021.1.17f1, 2021.2.0b7, 2022.1.0a5
Not reproducible with: 2019.3.0a2
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- "One or more data file missing for baking set NewScene Baking Set. Cannot load shared data." error in Player when a specific project is built
- Choosing new HDR Colour using RGB values breaks colour on Intensity Selectors
- Rendering/Decal Layer Mask options are different inside Prefab Mode and outside Prefab Mode when the project is upgraded to Unity 6
- Incorrect Realtime GI Light Probes baking when more than one Light Probe Group is used and "Baked Global Illumination" is enabled
- Hovering on the three-dot menu also highlights the tab header near it when not all tabs fit the bar
Resolution Note:
The Editor has undergone a very large visual redesign between 2018 and 2019, including using colors instead of textures to draw GUI button backgrounds. As such, both GUI.skin.button.normal.background and GUI.skin.button.active.background are identical (and null) and can't be used to implement the user's intended behavior.
There are a few solutions available as a workaround:
* Assigning any other texture to the GUIStyle.normal.background property will work as intended
* Using GUILayout.Toggle with "Button" for the style argument, which is made for this exact purpose. For example:
_pressed = GUILayout.Toggle(_pressed, _pressed ? "Change to N" : "Change to A", "Button");
* Upgrading your inspector to UI Toolkit, which has been the recommended solution for Editor content since Unity 2021