StyledTexturePreviewDrawer.cs 694 B

12345678910111213141516171819202122
  1. // Cristian Pop - https://boxophobic.com/
  2. using UnityEngine;
  3. using UnityEditor;
  4. namespace Boxophobic.StyledGUI
  5. {
  6. [CustomPropertyDrawer(typeof(StyledTexturePreview))]
  7. public class StyledTexturePreviewAttributeDrawer : PropertyDrawer
  8. {
  9. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  10. {
  11. var rect = GUILayoutUtility.GetRect(0, 0, Screen.width, 0);
  12. GUI.DrawTexture(rect, (Texture)property.objectReferenceValue, ScaleMode.StretchToFill, false);
  13. }
  14. public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  15. {
  16. return -2;
  17. }
  18. }
  19. }