Skip to main content

Class OptionalPropertyDrawer

Custom property drawer for Optional.

[CustomPropertyDrawer(typeof(Optional<>), true)]
public class OptionalPropertyDrawer : PropertyDrawer

Inheritance​

Methods​

CreatePropertyGUI(SerializedProperty)​

Create UI Toolkit based GUI for the property.

public override VisualElement CreatePropertyGUI(SerializedProperty property)

Parameters​

NameTypeDescription
propertySerializedPropertyThe SerializedProperty to make the custom GUI for.

Returns​

VisualElement — The element containing the custom GUI.

GetPropertyHeight(SerializedProperty, GUIContent)​

Specify how tall the GUI for this field is in pixels.

public override float GetPropertyHeight(SerializedProperty property, GUIContent label)

Parameters​

NameTypeDescription
propertySerializedPropertyThe SerializedProperty to make the custom GUI for.
labelGUIContentThe label of this property.

Returns​

float — The height in pixels.

OnGUI(Rect, SerializedProperty, GUIContent)​

Create IMGUI based GUI for the property.

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)

Parameters​

NameTypeDescription
positionRectRectangle on the screen to use for the property GUI.
propertySerializedPropertyThe SerializedProperty to make the custom GUI for.
labelGUIContentThe label of this property.
  • Methods
    • CreatePropertyGUI(SerializedProperty)
    • GetPropertyHeight(SerializedProperty, GUIContent)
    • OnGUI(Rect, SerializedProperty, GUIContent)