- Home /
Is there any way to hide the "Object picker" of an EditorGUILayout.ObjectField ?
I'm just asking if there is any possibility to hide the "Object Picker" (The little knob/menu next to an ObjectField in a custom Inspector. I have some cases where changes are disabled (DisableGroup) and I would like to also hide the knob while the content can not be changed.
would be a nice feature, but since even $$anonymous$$onoBehaviours are greyed out and has the picker, I doubt this exists. worth a feature request.
Answer by jaiyuan · Oct 27, 2020 at 11:55 AM
ObjectField without picker https://gist.github.com/unity3d-kr/d22b6a6f379947a9e6fdea3ef48df19f
Answer by jaiyuan · Oct 27, 2020 at 03:42 AM
I make the objectfield without picker.. You can see in my gist https://gist.github.com/unity3d-kr/d22b6a6f379947a9e6fdea3ef48df19f
Answer by mikelortega · Sep 13, 2021 at 03:48 PM
I would suggest to ignore the result and disable the ObjectField with EditorGUI.DisabledScope. It will show the object, you can use it to select it, but you cannot change the value.
Example:
using (new EditorGUI.DisabledScope(true))
{
EditorGUILayout.ObjectField(my_object, typeof(GameObject), true);
}
Hi (different acount here ^^) actually I was already using something similar
EditorGUI.BeginDisabledGroup(someCondition);
EditorGUILayout.ObjectField(my_object, typeof(GameObject), true);
EditorGUI.EndDisabledGroup();
However, as stated in the question the goal was not only to disable it (what I alread did) but also to not disaplay the knob at all ... reason behind it: I wanted to scale the field vertically to make it bigger but this looked pretty ugly because the knob got scaled vertically as well ^^