public void SetPolymorphicElementDrawCallback(StratusSerializedField serializedProperty) { this.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { if (!serializedProperty.isExpanded) { return; } // Get the drawer for the element type object element = serializedProperty.GetArrayElementAtIndex(index); Type elementType = element.GetType(); StratusSerializedEditorObject.ObjectDrawer drawer = StratusSerializedEditorObject.GetObjectDrawer(elementType); // Draw the element Rect position = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight); if (this.drawElementTypeLabel) { EditorGUI.LabelField(position, elementType.Name, elementLabelStyle); position.y += StratusEditorUtility.lineHeight; } drawer.DrawEditorGUI(position, element); }; }
public void SetPolymorphicElementHeightCallback(StratusSerializedField serializedProperty) { this.elementHeightCallback = (int indexer) => { if (!serializedProperty.isExpanded) { return(0); } else { StratusSerializedEditorObject.ObjectDrawer drawer = StratusSerializedEditorObject.GetObjectDrawer(serializedProperty.GetArrayElementAtIndex(indexer)); float height = drawer.height; // We add an additional line of height since we are drawing a label for polymorphic list if (this.drawElementTypeLabel) { height += StratusSerializedEditorObject.DefaultObjectDrawer.lineHeight; } return(height); } }; }