public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (property.propertyType == SerializedPropertyType.ObjectReference && (property.objectReferenceValue as Sprite) != null) { PreviewSpriteAttribute attr = attribute as PreviewSpriteAttribute; int height = attr.height; return(EditorGUI.GetPropertyHeight(property, label, true) + height + 10); } return(EditorGUI.GetPropertyHeight(property, label, true)); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // draw the normal property field EditorGUI.PropertyField(position, property, label, true); // draw the sprite if (property.propertyType == SerializedPropertyType.ObjectReference) { var sprite = property.objectReferenceValue as Sprite; if (sprite != null) { PreviewSpriteAttribute attr = attribute as PreviewSpriteAttribute; int height = attr.height; position.y += EditorGUI.GetPropertyHeight(property, label, true) + 5; position.height = height; DrawTexturePreview(position, sprite); } } }