Files
fnl/Assets/Extensions/Feel/MMTools/Editor/MMAttributes/MMNavMeshAreaMaskAttributeDrawer.cs

32 lines
919 B
C#
Raw Normal View History

2026-02-21 16:40:15 -08:00
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
namespace MoreMountains.Tools
{
[CustomPropertyDrawer(typeof(MMNavMeshAreaMaskAttribute))]
public class MMNavMeshAreaMaskAttributeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty serializedProperty, GUIContent label)
{
string[] navMeshAreaNames = GameObjectUtility.GetNavMeshAreaNames();
float positionWidth = position.width;
int maskValue = serializedProperty.intValue;
position.width = EditorGUIUtility.labelWidth;
EditorGUI.PrefixLabel(position, label);
position.x += EditorGUIUtility.labelWidth;
position.width = positionWidth - EditorGUIUtility.labelWidth;
EditorGUI.BeginChangeCheck();
maskValue = EditorGUI.MaskField(position, maskValue, navMeshAreaNames);
if (EditorGUI.EndChangeCheck())
{
serializedProperty.intValue = maskValue;
}
}
}
}
#endif