using AYellowpaper.SerializedCollections.Editor.Data; using AYellowpaper.SerializedCollections.Editor.States; using AYellowpaper.SerializedCollections.KeysGenerators; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using UnityEditor; using UnityEditor.IMGUI.Controls; using UnityEditorInternal; using UnityEngine; namespace AYellowpaper.SerializedCollections.Editor { #if ODIN_INSPECTOR [Sirenix.OdinInspector.Editor.DrawerPriority(Sirenix.OdinInspector.Editor.DrawerPriorityLevel.SuperPriority)] #endif [CustomPropertyDrawer(typeof(SerializedDictionary<,>), true)] public class SerializedDictionaryDrawer : PropertyDrawer { public const string KeyName = nameof(SerializedKeyValuePair.Key); public const string ValueName = nameof(SerializedKeyValuePair.Value); public const string SerializedListName = nameof(SerializedDictionary._serializedList); public const string LookupTableName = nameof(SerializedDictionary.LookupTable); public const int TopHeaderClipHeight = 20; public const int TopHeaderHeight = 19; public const int SearchHeaderHeight = 20; public const int KeyValueHeaderHeight = 18; public const bool KeyFlag = true; public const bool ValueFlag = false; public static readonly Color BorderColor = new Color(36 / 255f, 36 / 255f, 36 / 255f); public static readonly List NoEntriesList = new List(); internal static GUIContent DisplayTypeToggleContent { get { if (_displayTypeToggleContent == null) { var texture = AssetDatabase.LoadAssetAtPath("Assets/Plugins/SerializedCollections/Editor/Assets/BurgerMenu@2x.png"); _displayTypeToggleContent = new GUIContent(texture, "Toggle to either draw existing editor or draw properties manually."); } return _displayTypeToggleContent; } } private static GUIContent _displayTypeToggleContent; private Dictionary _arrayData = new(); public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (!_arrayData.ContainsKey(property.propertyPath)) _arrayData.Add(property.propertyPath, new SerializedDictionaryInstanceDrawer(property, fieldInfo)); _arrayData[property.propertyPath].OnGUI(position, label); } public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (!_arrayData.ContainsKey(property.propertyPath)) _arrayData.Add(property.propertyPath, new SerializedDictionaryInstanceDrawer(property, fieldInfo)); return _arrayData[property.propertyPath].GetPropertyHeight(label); } } }