summaryrefslogtreecommitdiff
path: root/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTexturePreviewDrawer.cs
blob: b95184aaac2d3a503a26b67919429f132db64597 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Cristian Pop - https://boxophobic.com/

using UnityEngine;
using UnityEditor;

namespace Boxophobic.StyledGUI
{
    [CustomPropertyDrawer(typeof(StyledTexturePreview))]
    public class StyledTexturePreviewAttributeDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var rect = GUILayoutUtility.GetRect(0, 0, Screen.width, 0);
            GUI.DrawTexture(rect, (Texture)property.objectReferenceValue, ScaleMode.StretchToFill, false);
        }

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            return -2;
        }
    }
}