Issue #175 open
Rainer Bernhardt
created an issue

I have a problem, where an empty group is shown when its members are hidden by attributes like "ShowIf", "HideIf", "HideInInspector" and so on.

Sample: bug.PNG

namespace Sirenix.OdinInspector.Demos {
    using System;
    using UnityEngine;

    public class BoxGroupExamples : MonoBehaviour {

        [BoxGroup("Should be hidden")]
        [ShowIf("ThisCondiditionIsMet")]
        public int Foo;

        private bool ThisCondiditionIsMet() {
            return false;
        }
    }
}

Comments (3)

  1. Tor Esa Vestergaard
    • changed status to open

    The problem is that the box group can't actually know whether its members are hidden or not.

    It tells Foo to draw, and then Foo immediately hits a drawer for the ShowIf attribute that checks the condition and decides to do nothing and return immediately. The box group doesn't know this, and has no real way of checking it either, especially not before it can decide whether or not to draw the enclosing box.

    The solution would be to apply the ShowIf attribute to the group itself - but since the group isn't a member, but merely an ephemeral "collection of members" that's become a thing in its own right, C#'s syntax allows for no easy or convenient way to do this. It's just a limitation of the attribute system, when it is used as C# normally allows.

    Now, we have Plans - with a capital P - to remedy this. On our roadmap (soon to be a page on our website), you can see that in patch 1.1, we intend to rework the internals of our property system, so that we can not only pull in attributes from the members they are declared on, but also from all other sorts of sources. So with this rework, you could (in a manner we haven't yet decided on the details of) specify that the group itself should have the ShowIf attribute applied.

    Until then, though, we're afraid there is no easy solution for this.

  2. Log in to comment