Skip to content

Bug: Caching drawers not compatible with arrays #40

@marc-antoine-girard

Description

@marc-antoine-girard

Description

Given an array of: { raw, Object, Object, raw }. Right-clicking on element [0] and choosing "Clear" or "Properties" will clear show the property of the last element. [3]
Doing the same thing on element [1] will apply to element [2] since it is the last element of its type.

This is caused by the fact that drawers are reused and the GenericMenu events are processed late in Unity's loop

This is also true for everything related to CustomObjectDrawer. When ReferenceDrawer.OnButtonClicked is called, the Property.propertyPath is always the last element of the same type (raw or Object).

Demo:

dog2

Given

public class CodeExample : MonoBehaviour, IDog
{
    public List<SerializableInterface<IDog>> dogs;
}

[Serializable]
public class Dog : IDog
{
    public int Age;
    public string Name;
}

public interface IDog { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions