MyBox
MyBox copied to clipboard
ConditionalFieldAttribute does not hide HeaderAttribute [Bug]
Yet another trivial and minor bug where ConditionalFieldAttribute does not hide HeaderAttribute, as shown in both of these screenshots:
- Screenshot_Field_Shown (
ShootAngleRotationSpeedis shown, true) - Screenshot_Field_Hidden (
ShootAngleRotationSpeedis hidden, but the header attribute is not.)
Codes used when encountering this:
[Separator("Shooter Targetting properties", true)]
[SerializeField, Tooltip("True if this shooter locks on to an enemy")]
private bool lockOn;
[ConditionalField("lockOn", false), SerializeField, Tooltip("Where this shot is angled towards."), Range(0f, 360f)]
private float shootingAngle;
[MustBeAssigned, ConditionalField("lockOn", true), SerializeField, Tooltip("The target this shooter is locking on to. (Play if null.)")]
private Transform targetTransform;
[Header("Angle Rotating Options")]
[SerializeField, ConditionalField("lockOn", false), Tooltip("The rotational speed applied to the shooting angle.")]
private float shootAngleRotationSpeed;
Though I can see the design idea in not fixing this. (Where there might be more than 1 field below the header, and it would look weird/bad if we hid the header at that situation.)
Maybe a parameter in the attribute that removes the header(if exists) when hidden? Or some checking to see if there is some fields below that doesn't have a header before hiding the header.
Probably not too possible.
Tried changing the header's attribute property directly, only to find out that you can't actually do so due to how attributes are tied to the binary files.
Saw nothing that could help the header in the UnityEditor API. (Though I might add that I am not too proficient with the UnityEditor API itself)
Could prob close this issue unless someone manages to find a way to hide the headers.
Let's consider this one as "by design". You may try to use SeparatorAttribute instead of the Header and I can add specific behavior for combination of Separator and ConditionalField.
I'll close this one when my ConditionalField attribute will work fine with SeparatorAttribure
this one in my TODO list now. I'll close this issue for now
Bump ;). Just ran into it
A note for the Andrew from (hopefully near) future I think I need to reimplement some Decorators and also finally reimplement ConfitionalFieldAttribute to use AttributeBase. It's one of the most important steps towards MyBox 2.0