void AddConnection(SplineComputer computer, int pointIndex) { Node node = (Node)target; Node.Connection[] connections = node.GetConnections(); if (EditorUtility.DisplayDialog("Link point?", "Add point " + (pointIndex + 1) + " to connections?", "Yes", "No")) { Undo.RecordObject(addComp, "Add connection"); Undo.RecordObject(node, "Add Connection"); if (connections.Length == 0) { switch (EditorUtility.DisplayDialogComplex("Align node to point?", "This is the first connection for the node, would you like to snap or align the node's Transform the spline point.", "No", "Snap", "Snap and Align")) { case 1: SplinePoint point = addComp.GetPoint(pointIndex); node.transform.position = point.position; break; case 2: SplineSample result = addComp.Evaluate(pointIndex); node.transform.position = result.position; node.transform.rotation = result.rotation; break; } } computer.ConnectNode(node, pointIndex); addComp = null; addPoint = 0; SceneView.RepaintAll(); Repaint(); } }
void HandleNodes(SplineComputer newSpline, int splitIndex) { List <Node> nodes = new List <Node>(); List <int> indices = new List <int>(); for (int i = splitIndex; i < spline.pointCount; i++) { Node node = spline.GetNode(i); if (node != null) { nodes.Add(node); indices.Add(i); spline.DisconnectNode(i); i--; } } for (int i = 0; i < nodes.Count; i++) { newSpline.ConnectNode(nodes[i], indices[i] - splitIndex); } }