WooshiiDev/HierarchyDecorator

Bug - Exceptions occrued and hierarchy is hidden if the game object name is same as the style prefix.

Opened this issue · 3 comments

Current Unity version used
I'm met on 2023.2.7.

Describe the bug
An exception occurred and objects in the hierarchy were hidden, below the game object that has the problem.

To Reproduce (If applicable)
Rename the any game object, "-", "=" or "+".

Screenshots
I have already fixed this on my fork, so no.

Additional context
Here is my fixed code.

// # HierarchyInfo.cs

private Rect GetLabelRect(Rect rect, string name, Settings settings)
{
    GUIStyle labelStyle = null;
    GUIContent labelGUI = new GUIContent();

    bool hasStyle = settings.styleData.TryGetStyleFromPrefix (name, out HierarchyStyle style);

    if (hasStyle)
    {
		int len = style.prefix.Length;
		if (len < name.Length)
		{
			labelStyle = style.style;
			name = style.FormatString(name.Substring(len + 1, name.Length - len - 1));
		}
		else
			labelStyle = EditorStyles.label;
    }
    else
    {
        labelStyle = EditorStyles.label;
    }

EDIT: Please confirm that the commit diff below is more suitable than this fix.

Hey there braces, cheers for this appreciate it.
If you'd like, can always do a PR for this, and I can accept it if you'd like if you want credit on this more 🙏

Otherwise I'll add this fix in myself, and still make sure to credit you in the version release info

Hi, okay I will try PR!

@WooshiiDev
I actually had no experience with pull requests.
So I looked into it, and it seemed difficult to submit a pull request because I had modified my forked repository quite a bit from the folder hierarchy. So I would be happy if you could fix it.
I just now learned for the first time it will show up like this if put an Issue url in the commit message,
Forget about the first code, as I think my latest modification is the most suitable.

Cheers!