1

It's not easy to specifically explain what the problem is, and the code through which the problem could be originating is extensive, and I am uncertain how to narrow it down beyond what I already have, given the extensive nature of the potentially problematic code, I have uploaded the code to Github, the best explanation I can provide is that when attempting to 'expand' on the 'NamePart' fields, it changes the name of the main field, adds an empty line between the dropdown and the field, and after the field, but does not display the fields of 'NamePart', the 'FamilyNames' field displays properly however, the code can be found here.

I have tried validating that the property drawers are setup properly, and that all fields are appropriately serialized, but I don't know what is even causing the problem let alone how to fix it.

The relevant sections of the code are below. First, in specifically the name generator property drawer:

protected override void DrawProperty ( Rect position, SerializedProperty property, GUIContent label, bool isPolymorphic )
{
    EditorGUI.BeginProperty ( position, label, property );
    Rect pos = new ( position.x, position.y, position.width, EditorGUI.GetPropertyHeight ( property.FindPropertyRelative ( "m_Feminine" ) ) );
    EditorGUI.PropertyField ( pos, property.FindPropertyRelative ( "m_Feminine" ));

    pos.y += pos.height + EditorGUIUtility.standardVerticalSpacing;
    pos.height = EditorGUI.GetPropertyHeight ( property.FindPropertyRelative ( "m_Masculine" ) );
    EditorGUI.PropertyField ( pos, property.FindPropertyRelative ( "m_Masculine" ));

    pos.y += pos.height + EditorGUIUtility.standardVerticalSpacing;
    pos.height = EditorGUI.GetPropertyHeight ( property.FindPropertyRelative ( "m_Neutral" ) );
    EditorGUI.PropertyField ( pos, property.FindPropertyRelative ( "m_Neutral" ));

    pos.y += pos.height + EditorGUIUtility.standardVerticalSpacing;
    pos.height = EditorGUI.GetPropertyHeight ( property.FindPropertyRelative ( "m_FamilyNames" ) );
    EditorGUI.PropertyField ( pos, property.FindPropertyRelative ( "m_FamilyNames" ) );
    EditorGUI.EndProperty ();
}

And also, in the polymorphic property drawer:

public sealed override void OnGUI ( Rect position, SerializedProperty property, GUIContent label )
{
    // ... 
    if (reference != null && propertyHeight > 0)
    {
        property.isExpanded = EditorGUI.Foldout ( labelRect, property.isExpanded, property.displayName, true );
    }
    else
    {
        EditorGUI.LabelField ( labelRect, label );
    }
1
  • I added some relevant sections of the problematic code. Any important context I left out should be included as well but it should at least have this much.
    – Ruzihm
    Commented Jun 7 at 20:45

1 Answer 1

1

As it would seem, I was having two separate problems that were entirely unrelated, the first problem was the displaying of fields problem, which was solved by ensuring that the 'property drawers' actually displayed their child properties (I'd missed that while I was trying to find the solution to both problems, which I had assumed had the same cause).

protected override void DrawProperty ( Rect position, SerializedProperty property, GUIContent label, bool isPolymorphic )
{
    EditorGUI.BeginProperty ( position, label, property );
    Rect pos = new ( position.x, position.y, position.width, EditorGUI.GetPropertyHeight ( property.FindPropertyRelative ( "m_Feminine" ) ) );
    EditorGUI.PropertyField ( pos, property.FindPropertyRelative ( "m_Feminine" ), true );

    pos.y += pos.height + EditorGUIUtility.standardVerticalSpacing;
    pos.height = EditorGUI.GetPropertyHeight ( property.FindPropertyRelative ( "m_Masculine" ) );
    EditorGUI.PropertyField ( pos, property.FindPropertyRelative ( "m_Masculine" ), true );

    pos.y += pos.height + EditorGUIUtility.standardVerticalSpacing;
    pos.height = EditorGUI.GetPropertyHeight ( property.FindPropertyRelative ( "m_Neutral" ) );
    EditorGUI.PropertyField ( pos, property.FindPropertyRelative ( "m_Neutral" ), true );

    pos.y += pos.height + EditorGUIUtility.standardVerticalSpacing;
    pos.height = EditorGUI.GetPropertyHeight ( property.FindPropertyRelative ( "m_FamilyNames" ) );
    EditorGUI.PropertyField ( pos, property.FindPropertyRelative ( "m_FamilyNames" ) );
    EditorGUI.EndProperty ();
}

The second was the part that caused the main fields label to change which was solved by using the 'property.displayName' instead of the 'input label parameter'

if (reference != null && propertyHeight > 0)
{
    property.isExpanded = EditorGUI.Foldout ( labelRect, property.isExpanded, property.displayName, true );
}
else
{
    EditorGUI.LabelField ( labelRect, property.displayName );
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.