SystemTypeReferencePropertyDrawer.ExcludedTypeCollectionGetter Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a function that returns a collection of types that are
to be excluded from drop-down. A value of null
specifies that
no types are to be excluded.
public:
static property Func<System::Collections::Generic::ICollection<Type ^> ^> ^ ExcludedTypeCollectionGetter { Func<System::Collections::Generic::ICollection<Type ^> ^> ^ get(); void set(Func<System::Collections::Generic::ICollection<Type ^> ^> ^ value); };
public static Func<System.Collections.Generic.ICollection<Type>> ExcludedTypeCollectionGetter { get; set; }
static member ExcludedTypeCollectionGetter : Func<System.Collections.Generic.ICollection<Type>> with get, set
Public Shared Property ExcludedTypeCollectionGetter As Func(Of ICollection(Of Type))
Property Value
Examples
Exclude a specific type from being selected:
private SerializedProperty someTypeReferenceProperty;
public override void OnInspectorGUI() {
serializedObject.Update();
ClassTypeReferencePropertyDrawer.ExcludedTypeCollectionGetter = GetExcludedTypeCollection;
EditorGUILayout.PropertyField(someTypeReferenceProperty);
serializedObject.ApplyModifiedProperties();
}
private ICollection<Type> GetExcludedTypeCollection() {
var set = new HashSet<Type>();
set.Add(typeof(SpecialClassToHideInDropdown));
return set;
}
Remarks
This property must be set immediately before presenting a class type reference property field using EditorGUI.PropertyField since the value of this property is reset to null
each time the control is drawn.
Since filtering makes extensive use of Contains(T) it is recommended to use a collection that is optimized for fast look ups such as HashSet for better performance.