From 376d6cc10818c14cb5e47412d19de021131fcb9a Mon Sep 17 00:00:00 2001 From: VladV Date: Wed, 25 Oct 2023 18:05:09 +0400 Subject: [PATCH] Fix LayerMask drawer --- Editor.Extras/Drawers/BuiltinDrawers.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Editor.Extras/Drawers/BuiltinDrawers.cs b/Editor.Extras/Drawers/BuiltinDrawers.cs index 7776602..a303a11 100644 --- a/Editor.Extras/Drawers/BuiltinDrawers.cs +++ b/Editor.Extras/Drawers/BuiltinDrawers.cs @@ -2,6 +2,7 @@ using TriInspector; using TriInspector.Drawers; using UnityEditor; +using UnityEditorInternal; using UnityEngine; [assembly: RegisterTriValueDrawer(typeof(IntegerDrawer), TriDrawerOrder.Fallback)] @@ -34,7 +35,7 @@ protected override string OnValueGUI(Rect position, GUIContent label, string val return EditorGUI.TextField(position, label, value); } } - + public class BooleanDrawer : BuiltinDrawerBase { protected override bool OnValueGUI(Rect position, GUIContent label, bool value) @@ -50,6 +51,7 @@ protected override int OnValueGUI(Rect position, GUIContent label, int value) return EditorGUI.IntField(position, label, value); } } + public class LongDrawer : BuiltinDrawerBase { protected override long OnValueGUI(Rect position, GUIContent label, long value) @@ -57,6 +59,7 @@ protected override long OnValueGUI(Rect position, GUIContent label, long value) return EditorGUI.LongField(position, label, value); } } + public class FloatDrawer : BuiltinDrawerBase { protected override float OnValueGUI(Rect position, GUIContent label, float value) @@ -85,7 +88,11 @@ public class LayerMaskDrawer : BuiltinDrawerBase { protected override LayerMask OnValueGUI(Rect position, GUIContent label, LayerMask value) { - return EditorGUI.LayerField(position, label, value); + var mask = InternalEditorUtility.LayerMaskToConcatenatedLayersMask(value); + var layers = InternalEditorUtility.layers; + + position = EditorGUI.PrefixLabel(position, label); + return EditorGUI.MaskField(position, mask, layers); } } @@ -160,7 +167,7 @@ protected override Bounds OnValueGUI(Rect position, GUIContent label, Bounds val public class GradientDrawer : BuiltinDrawerBase { private static readonly GUIContent NullLabel = new GUIContent("Gradient is null"); - + protected override Gradient OnValueGUI(Rect position, GUIContent label, Gradient value) { if (value == null) @@ -168,7 +175,7 @@ protected override Gradient OnValueGUI(Rect position, GUIContent label, Gradient EditorGUI.LabelField(position, label, NullLabel); return null; } - + return EditorGUI.GradientField(position, label, value); } }