protected override Rect GetChildPlaceholderRect(GraphNode parent, int index) { Rect rect = new Rect(Vector2.zero, NODE_SIZE); if (NodeAreas.TryGetValue(parent.GUID, out var area)) { Vector2 position = area.position; int idx = 0; foreach (var link in Graph.Links) { if (link.From.Node != parent) { continue; } if (idx == index) { break; } position.y = link.To.Node.Space; idx++; } rect.position = position; } return(rect); }
protected void UpdateNodeChildPos(GraphNode node) { if (node.MaxChildrenCount == 0) { return; } if (node.FoldChildren) { return; } if (Draging.Nodes.Contains(node)) { return; } Rect childrenArea = new Rect { position = node.Bounds.position + new Vector2(NODE_SPACE_WIDTH, -node.Space * 0.5f + NODE_SPACE_HEIGH * 0.5f), size = new Vector2(NODE_SPACE_WIDTH, node.Space) }; NodeAreas.Add(node.GUID, childrenArea); Vector2 startPos = childrenArea.position; int index = 0; foreach (var link in Graph.Links) { if (link.From.Node != node) { continue; } var child = link.To; if (Draging.Parent.GUID == node.GUID) { if (index == Draging.Index) { startPos.y += NODE_SPACE_HEIGH; } } if (!Draging.Nodes.Contains(child)) { Vector2 pos = startPos; startPos.y += child.Node.Space; pos.y += (child.Node.Space * 0.5f - NODE_SIZE.y * 0.5f); child.Node.Bounds = new Rect(pos, NODE_SIZE); UpdateNodeChildPos(child.Node); } ++index; } }