Attribute processors with EditableKeyValuePair type parameter only get processed once per type.

Issue #814 new
Antonio Rafael Antunes Miranda created an issue

1. What happened

Attribute processors with EditableKeyValuePair type parameter only get processed once per type.

2. How can we reproduce it

// DictionaryValueDropdownAttribute.cs
public class DictionaryValueDropdownAttribute : Attribute
{
    public string MemberName;
}

public class DictionaryValueDropdownAttributeProcessor<T1, T2> : OdinAttributeProcessor<EditableKeyValuePair<T1, T2>>
{
    private DictionaryValueDropdownAttribute attribute;

    public override bool CanProcessChildMemberAttributes(InspectorProperty parentProperty, MemberInfo member)
    {
        attribute = parentProperty.GetAttribute<DictionaryValueDropdownAttribute>();            

        return attribute != null;
    }

    public override void ProcessChildMemberAttributes(InspectorProperty property, MemberInfo member, List<Attribute> attributes)
    {
        attributes.Add(new ValueDropdownAttribute(attribute.MemberName));
    }
}

// SomeMonoBehaviour.cs
[DictionaryValueDropdown(MemberName = "@SomeMonoBehaviour.Values")]
public Dictionary<string, string> SomeDictionary1 = new Dictionary<string, string>();

[DictionaryValueDropdown(MemberName = "@SomeMonoBehaviour.OtherValues")]
public Dictionary<string, string> SomeDictionary2 = new Dictionary<string, string>();

private static List<string> Values => new List<string>
{
    "Value01",
    "Value02",
    "Value03",
};

private static List<string> OtherValues => new List<string>
{
    "OtherValue01",
    "OtherValue02",
    "OtherValue03",
};

Comments (0)

  1. Log in to comment