Wanzyee Studio

Mechanism to make nested UnityEditor.CustomPropertyDrawer possible. More...

Inherits PropertyDrawer.

Public Member Functions

override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
 OnGUI, draw inspector of the property. More...
 
override float GetPropertyHeight (SerializedProperty property, GUIContent label)
 Get the height of the property. More...
 

Static Public Member Functions

static PropertyDrawer CreateFallback (PropertyDrawer current)
 Create new fallback drawer for the specified custom UnityEditor.PropertyDrawer. More...
 

Detailed Description

Mechanism to make nested UnityEditor.CustomPropertyDrawer possible.

This'll search the fallback drawer for the caller drawer in the order below:

  1. All custom drawers for UnityEngine.PropertyAttribute order by PropertyAttribute.order.
  2. If exists, the custom drawer for the property type.
  3. Always valid, fallback to the default GUI.
  4. If any drawer of the chain doesn't use this, it just back to the built-in mechanism safely.

Here's the simple example to implement in your custom UnityEditor.PropertyDrawer:

private PropertyDrawer fallback;
private void Initialize(){
if(null == fallback) fallback = FallbackPropertyDrawer.CreateFallback(this);
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label){
Initialize();
//Do your modification, decoration, or function here.
fallback.OnGUI(position, property, label);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label){
Initialize();
return fallback.GetPropertyHeight(property, label);
}

3

Member Function Documentation

static PropertyDrawer CreateFallback ( PropertyDrawer  current)
static

Create new fallback drawer for the specified custom UnityEditor.PropertyDrawer.

Parameters
currentThe current drawer.
Returns
The fallback drawer.
override void OnGUI ( Rect  position,
SerializedProperty  property,
GUIContent  label 
)

OnGUI, draw inspector of the property.

Parameters
positionPosition.
propertyProperty.
labelLabel.
override float GetPropertyHeight ( SerializedProperty  property,
GUIContent  label 
)

Get the height of the property.

Parameters
propertyProperty.
labelLabel.
Returns
The property height.