Dreadrith / HierarchyPlus

A general improvement to the unity hierarchy such as component icons, guide lines, row coloring and settings for customization.
GNU General Public License v3.0
44 stars 5 forks source link

Guidelines offset #3

Open Dreadrith opened 8 months ago

Dreadrith commented 8 months ago

The guide lines in the hierarchy seem to be off center on higher resolution monitors. image My own screen is small and it wasn't easy to visualize differences since my own monitor displays it correctly. My own attempts just made it even more off center. The line drawing code already draws at the 1/2 locations such as offsetting left by 16/2 (size of the foldout icon) and offsetting down by half the height of the Rect it's in so I'm unsure what other approach should be done.

JustBuddy commented 6 months ago

If I change https://github.com/Dreadrith/HierarchyPlus/blob/1eb5350be1cd14fd686b33faae41e47d14542f7e/Editor/HierarchyPlus.cs#L269 to 13, it gets very close. 13.5 would probably make it look correct, but I can't use decimals there. Same for Line 294, second value. If it was 11.5 it would probably just align.

This is at 13/11 image

270 (34 -> 33) 308 (8 -> 7)

For all of those, I need an additional 0.5 to get it to look centered.

image

HakuSystems commented 2 months ago

Issue: Incorrect Math Calculation

The current math logic is incorrect. update the code at lines 335-337 to the following:

float marginWidth = hasChildren ? 14.0f : 1.9f;
float lineWidth = 14.0f * depth + 33.9f;
Rect lineRect = new Rect(rect.x - lineWidth, rect.y, lineWidth - marginWidth, rect.height);

By using float instead of int for width and height, the calculation becomes more precise and gives better results.

update the code at line 369 to this for more accurate round corners:

Vector3 middlePoint = new Vector3(basef - extraWidth - 7, rect.height / 2);

Images: Unity_A5xcVzVWkZ

Dreadrith commented 2 months ago

Thank you for the advice. I'll take a look at it next time I get the chance to work on HierarchyPlus 👍