Skip to content

Conversation

@JohannesDeml
Copy link
Contributor

@JohannesDeml JohannesDeml commented Jan 17, 2024

Description

Currently the label overlaps the button, if the label is very long, or the inspector very thin. The width is correctly calculated for the button, but somehow not applied in the list rendering (there seems to be a minsize for the button, but I didn't find the code that would enforce that). By drawing the label first, the button will render over the label if there is an overlap. This seems to be a bug with list renderings.

Before

Screen.Recording.2024-01-17.at.13.33.44-Handbrake.mp4

After

Screen.Recording.2024-01-17.at.13.34.34-Handbrake.mp4

Changes made

  • Draw label first
  • Draw foldout without any label

@JohannesDeml JohannesDeml force-pushed the bugfix/avoid-label-overlap branch from 1bbdb82 to 5e82006 Compare January 17, 2024 13:18
By drawing the label first we avoid the overlap. By drawing just the label without the foldout we need to work around a unity problem with indentation and apply that ourselves. The foldout property will then be rendered without gui content
@JohannesDeml JohannesDeml force-pushed the bugfix/avoid-label-overlap branch from 5e82006 to a8bcece Compare January 17, 2024 13:41
@JohannesDeml
Copy link
Contributor Author

With my first fix, the dropdown could not be used anymore, this is now fixed by only drawing the label first and the property later on with GUIContent.none

Demo video:

Screen.Recording.2024-01-17.at.14.41.36-Handbrake.mp4

@Maligan
Copy link

Maligan commented Feb 6, 2024

I would recommend to use output Rect from PrefixLabel as rectangle for control itself
There is a 2px spacing hardcoded in default unity drawlers so the dropdown now is 2px left than default ones.

Rect popupPosition = EditorGUI.PrefixLabel(foldoutLabelRect, label);

The bug exists in current version too, but now with prefix label there is a chance to not hardcode the 2px spacing :-)

@JohannesDeml
Copy link
Contributor Author

@Maligan Nice suggestion, makes the code also quite a bit cleaner!

@JohannesDeml
Copy link
Contributor Author

@mackysoft Did you already have time to look through my two prs? Those fixes would make the package usable for my project, otherwise it breaks too much.

@mackysoft
Copy link
Owner

I'm sorry. I was doing other work. I'll check it now.

@mackysoft mackysoft merged commit 69830f3 into mackysoft:main Feb 16, 2024
@mackysoft
Copy link
Owner

I've confirmed it's working. Thank you.

@JohannesDeml JohannesDeml deleted the bugfix/avoid-label-overlap branch February 18, 2024 18:43
@JohannesDeml
Copy link
Contributor Author

Thank you!

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

Successfully merging this pull request may close these issues.

3 participants