using UnityEngine; using UnityEditor; namespace AppleHills.Core.Settings.Editor { /// /// Custom property drawer for layer fields to display a dropdown with layer names /// [CustomPropertyDrawer(typeof(LayerAttribute))] public class LayerPropertyDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); // Draw a nice layer selection dropdown like the one in Unity inspector if (property.propertyType == SerializedPropertyType.Integer) { property.intValue = EditorGUI.LayerField(position, label, property.intValue); } else { EditorGUI.LabelField(position, label.text, "Use [Layer] with int fields only"); } EditorGUI.EndProperty(); } } /// /// Custom property drawer for LayerMask fields to display a mask dropdown with layer names /// [CustomPropertyDrawer(typeof(LayerMaskAttribute))] public class LayerMaskPropertyDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); // Draw a nice layer mask selection like the one in Unity inspector if (property.propertyType == SerializedPropertyType.LayerMask) { property.intValue = EditorGUI.MaskField(position, label, property.intValue, UnityEditorInternal.InternalEditorUtility.layers); } else { EditorGUI.LabelField(position, label.text, "Use [LayerMask] with LayerMask fields only"); } EditorGUI.EndProperty(); } } }