private void OnEnable()
    {
        Undo.undoRedoPerformed += UndoRedoPerformed;

        circlePath = target as CirclePath;
        circlePath.OnPathChanged(circlePath);
    }
 private void UndoRedoPerformed()
 {
     if (circlePath != null)
     {
         circlePath.OnPathChanged(circlePath);
     }
     else
     {
         Undo.undoRedoPerformed -= UndoRedoPerformed;
     }
 }
    public override void OnInspectorGUI()
    {
        float prevFillAmount = circlePath.FillAmount;
        bool  prevLoop       = circlePath.Loop;

        base.OnInspectorGUI();

        circlePath = target as CirclePath;

        SerializedObject so = new SerializedObject(circlePath);

        if (GUI.changed)
        {
            if (prevLoop != circlePath.Loop)
            {
                if (circlePath.Loop && circlePath.FillAmount != 1f)
                {
                    circlePath.SetFillAmount(1f);
                }

                if (prevLoop && circlePath.FillAmount == 1f)
                {
                    circlePath.SetFillAmount(0.99f);
                }

                prevFillAmount = circlePath.FillAmount;
            }

            if (prevFillAmount != circlePath.FillAmount)
            {
                if (circlePath.FillAmount == 1f && !circlePath.Loop)
                {
                    circlePath.SetLoop(true);
                }

                if (prevFillAmount == 1f && circlePath.Loop)
                {
                    circlePath.SetLoop(false);
                }

                prevLoop = circlePath.Loop;
            }

            circlePath.OnPathChanged(circlePath);
        }
    }