public override void OnInspectorGUI() { spline = target as Spline; if (selectedIndex >= 0 && selectedIndex < spline.points.Length) { DrawSelectedPointInspector(); } if (GUILayout.Button("Toggle Circuit")) { Undo.RecordObject(spline, "Toggle Circuit"); spline.circuit = !spline.circuit; EditorUtility.SetDirty(spline); } else if (GUILayout.Button("Add Segment")) { Undo.RecordObject(spline, "Add Segment"); EditorUtility.SetDirty(spline); selectedIndex = spline.points.Length; spline.AddSegment(); } else if (GUILayout.Button("Remove Segment")) { Undo.RecordObject(spline, "Remove Segment"); EditorUtility.SetDirty(spline); spline.RemoveSegment(); selectedIndex = -1; } }
public GSplineAnchor AddAnchorAutoTangent(Vector3 worldPositionNoOffset, int activeAnchorIndex = -1) { Vector3 position = worldPositionNoOffset + PositionOffset; Quaternion rotation = InitialRotation; Vector3 scale = InitialScale; GSplineAnchor a = new GSplineAnchor(); a.Position = position; a.Rotation = rotation; a.Scale = scale; Spline.Anchors.Add(a); if (activeAnchorIndex >= 0 && activeAnchorIndex < Spline.Anchors.Count) { Spline.AddSegment(activeAnchorIndex, Spline.Anchors.Count - 1); } return(a); }