TypePopupCache GetTypePopup(SerializedProperty property)
        {
            if (!m_TypePopups.TryGetValue(property.managedReferenceFieldTypename, out TypePopupCache result))
            {
                var state = new AdvancedDropdownState();

                Type baseType = property.GetManagedReferenceFieldType();
                var  popup    = new AdvancedTypePopup(
                    AppDomain.CurrentDomain.GetAssemblies()
                    .SelectMany(assembly => assembly.GetTypes())
                    .Where(p =>
                           p.IsClass &&
                           (p.IsPublic || p.IsNestedPublic) &&
                           !p.IsAbstract &&
                           !p.IsGenericType &&
                           baseType.IsAssignableFrom(p) &&
                           !k_UnityObjectType.IsAssignableFrom(p) &&
                           Attribute.IsDefined(p, typeof(SerializableAttribute))
                           ),
                    k_MaxTypePopupLineCount,
                    state
                    );
                popup.OnItemSelected += item => {
                    Type   type = item.Type;
                    object obj  = m_TargetProperty.SetManagedReference(type);
                    m_TargetProperty.isExpanded = (obj != null);
                    m_TargetProperty.serializedObject.ApplyModifiedProperties();
                };

                m_TypePopups.Add(property.managedReferenceFieldTypename, new TypePopupCache(popup, state));
            }
            return(result);
        }
 public TypePopupCache(AdvancedTypePopup typePopup, AdvancedDropdownState state)
 {
     TypePopup = typePopup;
     State     = state;
 }