-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathMaterialCompactTextureDrawer.cs
More file actions
37 lines (31 loc) · 1.07 KB
/
MaterialCompactTextureDrawer.cs
File metadata and controls
37 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using UnityEditor;
using UnityEngine;
namespace Toolbox.Editor.Drawers
{
public class MaterialCompactTextureDrawer : BaseMaterialPropertyDrawer
{
private readonly string tooltip;
public MaterialCompactTextureDrawer() : this(string.Empty)
{ }
public MaterialCompactTextureDrawer(string tooltip)
{
this.tooltip = tooltip;
}
protected override float GetPropertyHeightSafe(MaterialProperty prop, string label, MaterialEditor editor)
{
return EditorGUIUtility.singleLineHeight;
}
protected override void OnGUISafe(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
{
editor.TexturePropertyMiniThumbnail(position, prop, label, tooltip);
}
protected override bool IsPropertyValid(MaterialProperty prop)
{
#if UNITY_6000_3_OR_NEWER
return prop.propertyType == UnityEngine.Rendering.ShaderPropertyType.Texture;
#else
return prop.type == MaterialProperty.PropType.Texture;
#endif
}
}
}