5using UnityEngine.UIElements;
9 [CustomPropertyDrawer(typeof(ItemIDAttribute))]
10 public class ItemIdPropertyDrawer : PropertyDrawer
12 private static string[] namesCache;
14 public override VisualElement CreatePropertyGUI(SerializedProperty property)
16 namesCache = ItemIDsSettings.GetOrCreateSettings().itemIds.Select(i => i.name).ToArray();
18 return base.CreatePropertyGUI(property);
21 public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
23 if (namesCache ==
null || namesCache.Length != ItemIDsSettings.GetOrCreateSettings().itemIds.Count)
25 namesCache = ItemIDsSettings.GetOrCreateSettings().itemIds.Select(i => i.name).ToArray();
28 property.intValue = ItemIDsSettings.GetOrCreateSettings()
29 .itemIds[EditorGUI.Popup(
32 ItemIDsSettings.GetOrCreateSettings()
34 i => i.id == property.intValue