From 705d0dbf13d5592dbf8848d271ecd75f828ee98b Mon Sep 17 00:00:00 2001 From: Aurelio Provedo Date: Tue, 29 Mar 2022 23:23:46 +0200 Subject: [PATCH] ShowAssetPreview shows gameobject if a component has no preview assigned to it --- .../PropertyDrawers/ShowAssetPreviewPropertyDrawer.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/ShowAssetPreviewPropertyDrawer.cs b/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/ShowAssetPreviewPropertyDrawer.cs index 12c27c46..cdd203e0 100644 --- a/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/ShowAssetPreviewPropertyDrawer.cs +++ b/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/ShowAssetPreviewPropertyDrawer.cs @@ -72,6 +72,13 @@ private Texture2D GetAssetPreview(SerializedProperty property) if (property.objectReferenceValue != null) { Texture2D previewTexture = AssetPreview.GetAssetPreview(property.objectReferenceValue); + + if (previewTexture == null && property.objectReferenceValue is Component) + { + var gameObject = (property.objectReferenceValue as Component).gameObject; + previewTexture = AssetPreview.GetAssetPreview(gameObject); + } + return previewTexture; }