Custom Editor - FindProperty of parent class?

I am attempting to make a custom editor for a LayoutGroup derived class, but running into a problem in that properties of the parent LayoutGroup class don’t seem to be able to be found using FindProperty?

For example the padding property. In the code below, the padding property will not be found. Is there some special way of referencing a parent property? I have also tried using LayoutGroup.padding but that doesn’t work either.

using UnityEditor;
using omg.ui;

namespace omg.Editor.ui
{
    [CustomEditor(typeof(FlexibleLayoutGroup))]
    public class FlexibleLayoutGroupEditor : UnityEditor.Editor
    {
        private SerializedProperty padding;
        private SerializedProperty spacing;
        private SerializedProperty layoutType;
        private void OnEnable()
        {
            padding = serializedObject.FindProperty(nameof(FlexibleLayoutGroup.padding));
            spacing = serializedObject.FindProperty(nameof(FlexibleLayoutGroup.spacing));
            layoutType = serializedObject.FindProperty(nameof(FlexibleLayoutGroup.layoutType));
        }
       
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // EditorGUILayout.PropertyField(padding);
            EditorGUILayout.PropertyField(spacing);
            EditorGUILayout.PropertyField(layoutType);
           
            serializedObject.ApplyModifiedProperties();
        }
    }
}

Ok so for future posterity (AKA Google Search), I discovered that the padding property is really just a getter/setter for the underlying field which is named m_Padding.

I determined that by using the below snippet of code to print out all the properties inside the serializedObject.

            var prop = serializedObject.GetIterator();
            do
            {
                Debug.Log(prop.name);
            } while (prop.Next(true));
1 Like