in Scripts/Editor/CallbackHandlers/ValuePathMatcherPropertyDrawer.cs [107:222]
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var rect = new Rect(position)
{
height = EditorGUIUtility.singleLineHeight
};
var path = property.FindPropertyRelative(Properties.path);
var valueRefProp = property.FindPropertyRelative(Properties.witValueRef);
var editIconWidth = 24;
var pathRect = new Rect(rect);
pathRect.width -= editIconWidth;
var pathValue = GetPropertyPath(property);
if (IsEditingProperty(property))
{
if (!valueRefProp.objectReferenceValue)
{
pathRect.width -= WitStyles.IconButtonSize;
var value = EditorGUI.TextField(pathRect, path.stringValue);
if (value != path.stringValue)
{
path.stringValue = value;
}
pathRect.width += WitStyles.IconButtonSize;
var pickerRect = new Rect(pathRect)
{
x = pathRect.x + pathRect.width - 20,
width = 20
};
if (GUI.Button(pickerRect, WitStyles.ObjectPickerIcon, "Label"))
{
var id = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
EditorGUIUtility.ShowObjectPicker<WitValue>(
(WitValue) valueRefProp.objectReferenceValue, false, "", id);
}
}
else
{
EditorGUI.PropertyField(pathRect, valueRefProp, new GUIContent());
}
if (Event.current.commandName == "ObjectSelectorClosed")
{
valueRefProp.objectReferenceValue = EditorGUIUtility.GetObjectPickerObject();
}
pathValue = GetPropertyPath(property);
if (pathValue != currentEditPath && null != currentEditPath)
{
foldouts[currentEditPath] = false;
currentEditPath = GetPropertyPath(property);
foldouts[currentEditPath] = true;
}
}
else
{
if (valueRefProp.objectReferenceValue)
{
EditorGUI.LabelField(pathRect, valueRefProp.objectReferenceValue.name);
}
else
{
EditorGUI.LabelField(pathRect, path.stringValue);
}
}
var editRect = new Rect(rect)
{
x = pathRect.x + pathRect.width + 8
};
if (Foldout(rect, property))
{
if (GUI.Button(editRect, WitStyles.EditIcon, "Label"))
{
if (currentEditPath == pathValue)
{
currentEditPath = null;
}
else
{
currentEditPath = pathValue;
}
}
rect.x += WitStyles.IconButtonSize;
rect.width -= WitStyles.IconButtonSize;
rect.y += rect.height;
EditorGUI.PropertyField(rect, property.FindPropertyRelative(Properties.contentRequired));
rect.y += rect.height;
EditorGUI.PropertyField(rect, property.FindPropertyRelative(Properties.matchMethod));
if (ComparisonMethodsVisible(property))
{
rect.y += rect.height;
EditorGUI.PropertyField(rect,
property.FindPropertyRelative(Properties.comparisonMethod));
}
if (ComparisonValueVisible(property))
{
rect.y += rect.height;
EditorGUI.PropertyField(rect,
property.FindPropertyRelative(Properties.matchValue));
}
if (FloatingToleranceVisible(property))
{
rect.y += rect.height;
EditorGUI.PropertyField(rect,
property.FindPropertyRelative(Properties.floatingPointComparisonTolerance));
}
}
}