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
- [Quest] Pitch Shifter causes audio degradation on Quest 2 devices when sped up
- "GUI Error: Invalid GUILayout" and "NullReferenceException" are thrown when adding Scenes to "Scenes in Baking Set" in Adaptive Probe Volumes
- Inspector window not updating when switching GameObjects in Play Mode while having a VR headset connected
- “UnityException: GetInvalidFilenameChars” errors are thrown, and the Overlay Save Preset button becomes unusable when entering Play Mode with a shortcut while Overlay Save Preset window is opened
- "UnityException: GetName can only be called from the main thread." erors are thrown when the Shortcuts window is opened and entering Play Mode with a shortcut
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