MyBox icon indicating copy to clipboard operation
MyBox copied to clipboard

Conditional attributes don't work with properties

Open Tommigun1980 opened this issue 3 years ago • 0 comments

Hello and thanks for a great library!

However I found a slight issue (or lack of feature), namely that the conditional attributes (and possibly some other attributes, didn't check) only seem to work with fields and not with properties. So this won't work:

            [SerializeField]
            private bool someBool;
            public bool SomeBool
            {
                get { return this.someBool; }
            }

            [SerializeField]
            [ConditionalField(nameof(SomeClass.SomeBool))]
            private SomeInnerClassData someInnerClass;
            public SomeInnerClassData SomeInnerClass
            {
                get { return this.someInnerClass; }
            }

It does work if someBool is made public and bound to directly, but that breaks data encapsulation. It is quite convenient to have fields that are only editable through data.

So please consider adding support to ConditionalField attributes to also check for properties and not just fields!

Thank you so much.

Tommigun1980 avatar Apr 25 '22 14:04 Tommigun1980