This repository was archived by the owner on May 16, 2023. It is now read-only.
This repository was archived by the owner on May 16, 2023. It is now read-only.
Nodes on right side of graph aren't centered #2
Open
Description
It looks like the code to center the nodes on the right side of the graph isn't working correctly. For me these nodes were often offset at odd angles. I changed this method to fix it:
private void CenterTreeToRoot(Node.NodeInputSide side)
{
var children = _refTargetNode.GetChildren(side);
if (children.Count > 1)
{
float refTargetY = _refTargetNode.Position.y;
float size = _refTargetNode.GetLastChild(side).Position.y -
_refTargetNode.GetFirstChild(side).Position.y;
float actualY = _refTargetNode.GetFirstChild(side).Position.y;
float desiredY = refTargetY - size/2.0f;
float shiftY = desiredY - actualY;
for (int i = 0; i < children.Count; ++i)
{
children[i].ForeachChildrenRecursively(side, (node) => node.SetPositionY(node.Position.y + shiftY));
}
}
}
Metadata
Metadata
Assignees
Labels
No labels