Added PredrawerModifier to help modify either SerializedProperty or GUIContent before drawing

This commit is contained in:
Anders Ejlersen 2021-12-04 11:32:57 +01:00
parent 6321fcc107
commit e0fc2c1e05
7 changed files with 62 additions and 3 deletions

View file

@ -15,8 +15,16 @@ namespace Module.Inspector.Editor
return;
label.tooltip = result.tooltip;
for (var i = 0; i < result.predrawerModifiers.Count; i++)
{
EditorPropertyUtility.ResultValue<PredrawerModifierPropertyAttribute, PredrawerModifierPropertyDrawer> value = result.predrawerModifiers[i];
value.drawer.Modify(value.attribute, property, label);
}
bool prevEnabled = GUI.enabled;
GUI.enabled = accessType == EAccessType.Enabled;
// TODO: What to do with [Obsolete]?
if (result.draw != null)
{
@ -50,7 +58,7 @@ namespace Module.Inspector.Editor
return accessType != EAccessType.Hidden ? EditorGUI.GetPropertyHeight(property, label) : 0.0f;
}
private EAccessType GetAccessType(SerializedProperty property, EditorPropertyUtility.Result result)
private static EAccessType GetAccessType(SerializedProperty property, EditorPropertyUtility.Result result)
{
if (result.accessModifiers.Count == 0)
return EAccessType.Enabled;