in Scripts/Editor/Windows/PropertyDrawers/WitPropertyDrawer.cs [40:97]
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
// Return error
if (property.serializedObject == null)
{
string missingText = GetLocalizedText(property, LocalizedMissingKey);
WitEditorUI.LayoutErrorLabel(missingText);
return;
}
// Show foldout if desired
string titleText = GetLocalizedText(property, LocalizedTitleKey);
if (FoldoutEnabled)
{
property.isExpanded = WitEditorUI.LayoutFoldout(new GUIContent(titleText), property.isExpanded);
if (!property.isExpanded)
{
return;
}
}
// Show title only
else
{
WitEditorUI.LayoutLabel(titleText);
}
// Indent
GUILayout.BeginVertical();
EditorGUI.indentLevel++;
// Pre fields
OnGUIPreFields(position, property, label);
// Iterate all subfields
WitPropertyEditType editType = EditType;
const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
Type fieldType = fieldInfo.FieldType;
if (fieldType.IsArray)
{
fieldType = fieldType.GetElementType();
}
FieldInfo[] subfields = fieldType.GetFields(flags);
for (int s = 0; s < subfields.Length; s++)
{
FieldInfo subfield = subfields[s];
if (ShouldLayoutField(property, subfield))
{
LayoutField(s, property, subfield, editType);
}
}
// Post fields
OnGUIPostFields(position, property, label);
// Undent
EditorGUI.indentLevel--;
GUILayout.EndVertical();
}