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();
}
}
}