I’m trying to build a small spline editor. Spline objects contain a List<> of SplinePoints. A spline point is a game object with a SplinePoint script. I now want to detect when the user deletes the GameObject so I can automatically remove the object from the List.
I tried OnDestroy() but from what I tried and what I read it only works in play mode.
SplinePoint.cs
[ExecuteInEditMode]
private void OnDestroy()
{
print("foo");
SplineEditor.DeletePoint(this);
}
SplineEditor.cs
public static void DeletePoint(SplinePoint sender)
{
print("Deleting...");
// TODO Fix this
sender.ParentSpline.splinePoints.Remove(sender);
}