private static void drawPath(VectorPath2D path, Color color) { Vector2[] vertices = path.GetWorldPoints(); if (vertices == null) { return; } for (int i = 0; i < vertices.Length; i++) { int ii = (i + 1) % vertices.Length; // Draw edge if (ii != 0) { Gizmos.color = color; Gizmos.DrawLine(vertices[i], vertices[ii]); } // Draw vertex if (Selection.activeGameObject == path.gameObject) { Gizmos.color = ColorPalletReader.GetVertexColor(ColorStates.PATH); if (i == _selectedVertex) { Gizmos.color = ColorPalletReader.GetVertexColor(ColorStates.SELECTED); } Gizmos.DrawSphere(vertices[i], BrushSettingsWindow.VertexSize); if (BrushSettingsWindow.ShowVertexInfo == true) { Handles.Label(vertices[i] + new Vector2(0.1f, 0.4f), path.GetLocalPoint(vertices[i]).ToString()); } } } }
public static void UpdateVertexPosition(this VectorPath2D path, Vector3 newPosition, int selectedVertex) { Undo.RecordObject(path, string.Format("Move vertex {0} in {1}", selectedVertex, path.name)); Vector2[] vertices = path.points; vertices[selectedVertex] = path.GetLocalPoint(newPosition); path.points = vertices; }