Prefix label greyed out when following component disabled

I have a problem where a prefix label in a custom inspector gets greyed out when only the first following component is disabled. How can I fix this? I have tried adding a pseudo-component with zero width before the disabled component, but it still takes up some spaces and creates a glitched look.


Here you can see the prefix label turns grey because the following component is disabled, even when explicitly enabling the GUI beforehand:

EditorGUILayout.BeginHorizontal ();
GUI.enabled = true; // This has no effect
EditorGUILayout.PrefixLabel ("Grid snapping");
GUI.enabled = mb.gridOption > 0;
bool decrement = GUILayout.Button ("-", layoutOptions);
GUI.enabled = true;
// ...
EditorGUILayout.EndHorizontal ();

What might I be able to do about this?

I had same question but I couldn’t find a good answer with Google. So here is a way I found to fix this problem:


    EditorGUILayout.PrefixLabel ("Grid snapping");


    EditorGUILayout.LabelField ("Grid snapping", GUILayout.Width(EditorGUIUtility.labelWidth - 4));

I don’t know if it is a good way to do, but this one seems work. I use Unity 2018.3.14f1.