1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

UI Sharpness complete fix

Complete fix to address bluriness of the UI in the Node Editor Window. Previous fixes were not all encompassing and failed to account for now even dimensions of Editor Window.
This commit is contained in:
NoiseCrime 2019-02-18 11:53:38 +00:00
parent 0f5539e077
commit b158540d34
2 changed files with 5 additions and 8 deletions

View File

@ -137,12 +137,7 @@ namespace XNodeEditor {
Repaint();
}
} else if (e.button == 1 || e.button == 2) {
Vector2 tempOffset = panOffset;
tempOffset += e.delta * zoom;
// Round value to increase crispyness of UI text
tempOffset.x = Mathf.Round(tempOffset.x);
tempOffset.y = Mathf.Round(tempOffset.y);
panOffset = tempOffset;
panOffset += e.delta * zoom;
isPanning = true;
}
break;
@ -277,6 +272,7 @@ namespace XNodeEditor {
GenericMenu menu = new GenericMenu();
NodeEditor.GetEditor(hoveredNode).AddContextMenuItems(menu);
menu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
e.Use(); // Fixes copy/paste context menu appearing in Unity 5.6.6f2 - doesn't occur in 2018.3.2f1 Probably needs to be used in other places.
} else if (!IsHoveringNode) {
GenericMenu menu = new GenericMenu();
graphEditor.AddContextMenuItems(menu);

View File

@ -123,8 +123,9 @@ namespace XNodeEditor {
public Vector2 GridToWindowPositionNoClipped(Vector2 gridPosition) {
Vector2 center = position.size * 0.5f;
float xOffset = (center.x * zoom + (panOffset.x + gridPosition.x));
float yOffset = (center.y * zoom + (panOffset.y + gridPosition.y));
// UI Sharpness complete fix - Round final offset not panOffset
float xOffset = Mathf.Round(center.x * zoom + (panOffset.x + gridPosition.x));
float yOffset = Mathf.Round(center.y * zoom + (panOffset.y + gridPosition.y));
return new Vector2(xOffset, yOffset);
}