public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { position = position.SetHeight(DEFAULT_FIELD_HEIGHT); var gameObject = property.FindPropertyRelative("obj"); EditorGUI.PropertyField(position, gameObject, label); int indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var assetPreviewRect = position.SetX(position.x + EditorGUIUtility.labelWidth) .SetY(position.y + DEFAULT_FIELD_HEIGHT) .SetHeight(5 * DEFAULT_FIELD_HEIGHT) .SetWidth(5 * DEFAULT_FIELD_HEIGHT); var gameObjectId = gameObject.objectReferenceInstanceIDValue; if (gameObjectId > 0) //Exists { Texture2D assetPreview = AssetPreview.GetAssetPreview(gameObject.objectReferenceValue); if (!AssetPreview.IsLoadingAssetPreview(gameObjectId) && assetPreview != null) { EditorCustomGUIUtility.DrawPreviewTexture(assetPreviewRect, assetPreview); } } EditorGUI.indentLevel = indentLevel; }
public override void OnInspectorGUI() { serializedObject.Update(); DrawPropertiesExcluding(serializedObject, new [] { "Assets" }); EditorCustomGUIUtility.ShowList(serializedObject.FindProperty("Assets")); serializedObject.ApplyModifiedProperties(); }