using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(PathfindingLinkMonoBehaviour))]
public class PathfindingLinkEditor : Editor {
    private void OnSceneGUI() {
        PathfindingLinkMonoBehaviour pathfindingLinkMonoBehaviour = (PathfindingLinkMonoBehaviour)target;
        EditorGUI.BeginChangeCheck();
        Vector3 newLinkPositionA = Handles.PositionHandle(pathfindingLinkMonoBehaviour.LinkPositionA, Quaternion.identity);
        Vector3 newLinkPositionB = Handles.PositionHandle(pathfindingLinkMonoBehaviour.LinkPositionB, Quaternion.identity);

        if (!EditorGUI.EndChangeCheck()) return;

        Undo.RecordObject(pathfindingLinkMonoBehaviour, "Change Link Position");
        pathfindingLinkMonoBehaviour.LinkPositionA = newLinkPositionA;
        pathfindingLinkMonoBehaviour.LinkPositionB = newLinkPositionB;
    }
}