Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

HideInInspector prevent EditorGUILayout.PropertyField from drawing SerializedProperty

Discussion in 'Immediate Mode GUI (IMGUI)' started by Garrettec, Oct 19, 2015.

  1. Garrettec

    Garrettec

    Joined:
    Nov 26, 2012
    Posts:
    98
    I hid several fields (which are custom classes with tons of parameters) from showing in default editor to place them in more appropriate place in my custom editor section. I was trying to figure out why EditorGUILayout.PropertyField is not working for this field. Only after day of investigation, and when I almost finish coding my own control for drawing PropertyField I realized that [HideInInspector] is the key figure in this story.

    Is such behaviour correct? It seems not, all other EditorGUILayout controls work fine with "Hidden Fields"...
     
  2. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    Hey there,

    Yes this is 100% correct behavior this is what gives you the true power of PropertyDrawers. They are there to be reusable. The fact that you can write a whole editor window and still have custom drawers take effect is very very useful. Otherwise you would have to do a lot of repeat work.

    Cheers
     
  3. Garrettec

    Garrettec

    Joined:
    Nov 26, 2012
    Posts:
    98
    Hi, sorry for long reply, have no time to check your statement.

    Today I made a little experiment and find out that objects of custom classes, which have PropertyDrawers, are drawn by EditorGUILayout.PropertyField, even if they marked as [HideInInspector]. Hence I still consider aforementioned behaviour like "Broken One", because it prevent us from using EditorGUILayout.PropertyField in conjunction with DrawDefaultInspector().

    Cheers