public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        spline = target as BezierSpline;
        EditorGUI.BeginChangeCheck();
        bool loop = EditorGUILayout.Toggle("Loop", spline.Loop);
        int  linearApproxSteps = EditorGUILayout.IntField("LinearApproxSteps", spline.LinearApproxSteps);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Spline InspectorChange");
            EditorUtility.SetDirty(spline);
            spline.Loop = loop;
            spline.LinearApproxSteps = linearApproxSteps;
        }
        if (selectedIndex >= 0 && selectedIndex < spline.ControlPointCount)
        {
            DrawSelectedPointInspector();
        }


        if (GUILayout.Button("Add Curve"))
        {
            Undo.RecordObject(spline, "AddCurve");
            spline.AddCurve();
            EditorUtility.SetDirty(spline);
        }
        if (GUILayout.Button("ResetCurve"))
        {
            Undo.RecordObject(spline, "ResetCurve");
            spline.Reset();
            EditorUtility.SetDirty(spline);
        }
        if (GUILayout.Button("DrawTextMarker"))
        {
            Undo.RecordObject(spline, "Draw text marker");
            spline.AddDistanceMarker();
            EditorUtility.SetDirty(spline);
        }
    }