Skip to content

Event Reference Updater and IEnumerables #52

@slojanko

Description

@slojanko

Hey, I noticed the GenericUpdateEventReferencePath case for updating paths from Guid doesn't handle IEnumerables correctly sometimes. In case the elements are structs, the problem lies within FindSubObject, which returns a copy of the IEnumerable element.

I don't have a suggestion for a fix yet, because it's written in a generic way, what has to be changed is the SetValue towards the end of the Execute delegate should propagate the change upwards, not just call SetValue on the copy.
The hierarchy of the fields path can be quite complex _list[0]._list1[51]._struct._eventReference.

                    Execute: (data, rootObject) =>
                    {
                        object target = FindSubObject(rootObject, data[0]);

                        System.Type targetType = target.GetType();
                        FieldInfo field = targetType.GetField(data[1], DefaultBindingFlags);

                        EventReference value = (EventReference)field.GetValue(target);
                        value.Path = data[3];

                        field.SetValue(target, value);
                        SetSubObject(rootObject, data[0], value);

                        EditorUtility.SetDirty(rootObject);
                    }

It's reproducible in 2.0.3 and master.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions