Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom filters do not work when the field hierarchy is deep. #4

Open
Shi-553 opened this issue Feb 2, 2023 · 0 comments
Open

Custom filters do not work when the field hierarchy is deep. #4

Shi-553 opened this issue Feb 2, 2023 · 0 comments

Comments

@Shi-553
Copy link

Shi-553 commented Feb 2, 2023

There is a bug where custom filters do not work when the field hierarchy is deep.
This is necessary if you want to wrap type filtering in a class.

For example, Once this is corrected, it can be defined as follows

[System.Serializable]
public class SerializeInterface<T> where T : class
{
    [SerializeField, Pickle(FilterMethodName = nameof(CustomFilter))]
    Object obj;

    public T Interface
    {
        get => obj as T;
        set => obj = value as Object;
    }

    private bool CustomFilter(ObjectTypePair item)
    {
        return item.Object is T;
    }
}

It can be used like this

public class Foo: MonoBehaviour
{
    [SerializeField]
    SerializeInterface<IBar> bar;
    [SerializeField]
    SerializeInterface<IBar>[] bars;
}

If you format it using custom property drawers, it will look like this
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant