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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
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