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

(bug) Excessive Spacing with the ShowIf/HideIf attributes in Nested Arrays #371

Open
axelorca opened this issue Aug 25, 2023 · 1 comment

Comments

@axelorca
Copy link

axelorca commented Aug 25, 2023

Hi there!
I'm encountering an issue with the ShowIf and HideIf attributes. It doesn't seem to be removing the spacing between properties. I'm not using any Space attribute, the spacings are just the default spacing value between a property and another
bug
I kind of got around it by using [Space(negative int)] but it doesn't give pleasing results...
Any possibility to fix this??
PS: The variables are displayed in nested arrays.

@axelorca axelorca changed the title (bug) Excessive Spacing with the ShowIf/HideIf attributes (bug) Excessive Spacing with the ShowIf/HideIf attributes in Nested Arrays Aug 25, 2023
@ninjuit
Copy link

ninjuit commented Oct 25, 2023

If you go into the NaughtyAttributes codebase, find PropertyDrawerBase.cs, and replace GetPropertyHeight with this, it will fix it.

sealed override public float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
    bool visible = PropertyUtility.IsVisible(property);
    if (!visible)
    {
        return -EditorGUIUtility.standardVerticalSpacing;
    }
    return GetPropertyHeight_Internal(property, label);
}

Basically, even when an element is hidden, Unity still draws the default height for a new element, so I solved it by just applying a negative height for the hidden elements.

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

2 participants