private void OnSceneGUI()
    {
        spline = target as Spline2DComponent;

        DrawPoints();
    }
    public override void OnInspectorGUI()
    {
        spline = target as Spline2DComponent;

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Point"))
        {
            Undo.RecordObject(spline, "Add Point");
            AddNewPoint();
        }

        if (selectedIndex == -1)
        {
            GUI.enabled = false;
        }
        if (GUILayout.Button("Remove Point"))
        {
            Undo.RecordObject(spline, "Remove Point");
            RemovePoint();
        }
        GUILayout.EndHorizontal();
        if (selectedIndex == -1)
        {
            GUI.enabled = true;
        }
        DrawSelectedPointInspector();

        // DON'T use the default inspector, it will bypass setters and we need
        // those to be called to properly dirty the state
        EditorGUI.BeginChangeCheck();
        bool closed = EditorGUILayout.Toggle("Closed", spline.IsClosed);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Toggle Closed");
            spline.IsClosed = closed;
        }
        EditorGUI.BeginChangeCheck();
        float curve = EditorGUILayout.FloatField("Curvature", spline.Curvature);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Set Curvature");
            spline.Curvature = curve;
        }
        EditorGUI.BeginChangeCheck();
        int lenSamples = EditorGUILayout.IntSlider("Length Sampling", spline.LengthSamplesPerSegment, 1, 20);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Set Length Sampling");
            spline.LengthSamplesPerSegment = lenSamples;
        }


        EditorGUILayout.BeginHorizontal();
        EditorGUI.BeginChangeCheck();
        bool showDistance = EditorGUILayout.Toggle("Show Distance", spline.showDistance);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Toggle Show Distance");
            spline.showDistance = showDistance;
        }
        EditorGUI.BeginChangeCheck();
        float dist = EditorGUILayout.FloatField("Interval", spline.distanceMarker);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Set Distance Interval");
            spline.distanceMarker = dist;
        }
        EditorGUILayout.EndHorizontal();

        EditorGUI.BeginChangeCheck();
        bool showNormals = EditorGUILayout.Toggle("Show Normals", spline.showNormals);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(spline, "Toggle Show Normals");
            spline.showNormals = showNormals;
        }
    }