Hi all,
I’m having a weird trouble with custom Property Drawer. My current setup is like this (fairly complicated)
A Custom Editor Window that has:
- A list that contains:
- Class WheelInfo. That contains:
- Struct SuspensionData.
For SuspensionData drawer, I just followed the Unity Live Training, because I just want to replace the float’s with sliders, and foldouts to clean things up.
For wheelInfo, same, Just to contain SuspensionData and some sliders.
But things turns out like this:
As you can see, the foldout of each element in the list is gone. The foldout for each suspensionData struct inside each WheelInfo is also gone, and the layout is messed up. I have no idea why this is happening, eventhough I’m following 100% the Live Training and the Documentation example.
Here are the codes:
[CustomPropertyDrawer(typeof(WheelInfo))]
public class WheelInfoInspector : PropertyDrawer {
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
//base.OnGUI(position, property, label);
EditorGUI.BeginProperty(position, label, property);
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
EditorGUILayout.PropertyField(property.FindPropertyRelative("suspension"), true);
EditorGUI.EndProperty();
}
[CustomPropertyDrawer(typeof(SuspensionData))]
public class SuspensionInspector : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
//base.OnGUI(position, property, label);
EditorGUI.BeginProperty(position, label, property);
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
springFold = EditorGUILayout.Foldout(springFold, new GUIContent("Spring", "Spring Settings"), true);
if (springFold)
{
EditorGUILayout.Slider(property.FindPropertyRelative("suspensionTravel"), 0f, 10f);
}
EditorGUI.EndProperty();
}
}
By the way, is there a way to render the default property drawer, and then draw extra things along with the default layout?
Thank you very much.