Custom Inspector Undo Functionality when directly changing SerializedProperties

Hello,
I’m relatively new at working with custom Inspector/Editor. The serialized properties have been very helpful for me since they include the automatic undo functionality. But this doesn’t seem to work when you edit the value of the serialized property directly. (in this case .boolValue)

public override void OnInspectorGUI()
    {
        
        EditorGUILayout.LabelField("Set Selection on Activation", EditorStyles.boldLabel);
        EditorGUI.BeginChangeCheck();
        bool _tryFind = tryFindSelectableInChildren.boolValue;
        if(_tryFind) _selected =1;
        else _selected = 0;
        serializedObject.Update();

        _selected = EditorGUILayout.Popup(new GUIContent
                 ("Select on Activation", "shortened"),_selected,popupContent);
        EditorGUILayout.BeginVertical(EditorStyles.objectField);
        if(_selected==0)
        {
            _tryFind = false;
            EditorGUILayout.PropertyField(preSelected);
        }
        else if(_selected==1)
        {
            _tryFind = true;
            EditorGUILayout.PropertyField(parentOfSelectables,new GUIContent("Set Parent"));
        }
        tryFindSelectableInChildren.boolValue = _tryFind;
        EditorGUILayout.EndVertical();
        serializedObject.ApplyModifiedProperties();
}

How do I record the changes I’m doing to “tryFindSelectableInChildren” in my undo function?

Assign the bool to a temporary variable, then in your EndChangeCheck, record and set _tryFind like this example:

That should work, but you might not need Undo.RecordObject for value types like bools, I can’t remember off the top of my head.