using System; using System.Linq; using System.Reflection; using RPGCoreCommon.Helpers.CustomTypes; using UnityEditor; using UnityEditor.UIElements; using UnityEngine; using UnityEngine.UIElements; namespace RPGCoreCommon.Helpers.Editor.Drawers { [Serializable] [CustomPropertyDrawer(typeof(SerializableDictionary<,>), true)] public class SerializableDictionaryDrawer : PropertyDrawer { [SerializeField] private VisualTreeAsset _visualTreeAsset; private SerializedProperty _property; private SerializedProperty _tempKeyProperty; private SerializedProperty _pairsProperty; private SerializableDictionaryAttribute _sdAttribute; private Type _keyType; private Type _valueType; public override VisualElement CreatePropertyGUI(SerializedProperty property) { _property = property; _sdAttribute = fieldInfo.GetCustomAttribute() ?? new SerializableDictionaryAttribute(); _tempKeyProperty = property.FindPropertyRelative("_tempKey"); _pairsProperty = property.FindPropertyRelative("_pairs"); var genericTypes = property.boxedValue.GetType().FindGenericDefinitionType(typeof(SerializableDictionary<,>)).GetGenericArguments(); _keyType = genericTypes[0]; _valueType = genericTypes[1]; var root = _visualTreeAsset.CloneTree(); root.Q