Class SystemTypeReferencePropertyDrawer
Custom property drawer for SystemType properties.
Namespace: Microsoft.MixedReality.Toolkit.Editor
Assembly: cs.temp.dll.dll
Syntax
public class SystemTypeReferencePropertyDrawer : PropertyDrawer
Properties
ExcludedTypeCollectionGetter
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.
Declaration
public static Func<ICollection<Type>> ExcludedTypeCollectionGetter { get; set; }
Property Value
Type | Description |
---|---|
Func<ICollection<Type>> |
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.
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;
}
Methods
GetPropertyHeight(SerializedProperty, GUIContent)
Declaration
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
Parameters
Type | Name | Description |
---|---|---|
SerializedProperty | property | |
GUIContent | label |
Returns
Type | Description |
---|---|
Single |
OnGUI(Rect, SerializedProperty, GUIContent)
Declaration
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
Parameters
Type | Name | Description |
---|---|---|
Rect | position | |
SerializedProperty | property | |
GUIContent | label |