How to place a property underneath some other properties (property drawer of serialized object)?

Hi!

My issue: How can I make a property drawer draw the properties of a serialized object not only next to each other but in a grid (underneath each other)?

My example: A serialized object (“Feature.cs”) consists of a structure holding strings (Name, Label) and an array of Sprites (FeatureValues). For each element in Feature, the property drawer should show Name and Label next to each other and FeatureValues right underneath Name. In fact, FeatureValues should appear after clicking on a foldout (or toggle) located underneath Name.

This is how far I get with the documentation of the property drawer, but I can’t figure hout how to make the FeatureValues property appear underneath each Name with a dropdown.

This is what I manage

94692-unbenannt-1.jpg

But I want it to appear like

94693-unbenannt-2.jpg

Can anybody help me out here?
Thanks a lot in advance
Jana


Here is the code for the structure and the property drawer that I use.

Feature.cs

using UnityEngine;
using System.Collections;

[System.Serializable]
public struct Feature
{
    public string Name;
    public string Label;
    public Sprite[] FeatureValues;
}

FeatureDrawer.cs

using UnityEngine;
using UnityEditor;

[CustomPropertyDrawer (typeof (Feature))]
public class FeatureDrawer : PropertyDrawer
{
    public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);

        var indent = EditorGUI.indentLevel;
        EditorGUI.indentLevel = 0;

        var i = 45;
        var height = GetPropertyHeight(property, label);
        var NumberRect = new Rect(position.x + i, position.y, 40, position.height);
        var NameRect = new Rect(position.x + i + 50, position.y, 70, position.height);
        var DisplayAsRect = new Rect(position.x + i + 130, position.y, 60, position.height);
        var LabelRect = new Rect(position.x + i + 195, position.y, position.width - i - 195, position.height);
        var FoldoutRect = new Rect(position.x + i + 11, position.y + position.height, position.width, position.height);


        // Draw fields - pass GUIContent.none to each so they are drawn without labels
        EditorGUI.LabelField(NumberRect, "Name");
        EditorGUI.PropertyField(NameRect, property.FindPropertyRelative("Name"), GUIContent.none);
        EditorGUI.LabelField(DisplayAsRect, " label as");
        EditorGUI.PropertyField(LabelRect, property.FindPropertyRelative("Label"), GUIContent.none);
        EditorGUI.Toggle(FoldoutRect, false, "Feature Values");

        // Set indent back to what it was
        EditorGUI.indentLevel = indent;

        EditorGUI.EndProperty();

    }
}

You should be able to just use a property field for the FeatureValues property. Something like this:

EditorGUI.PropertyField(FoldoutRect, property.FindPropertyRelative("FeatureValues"), true);