Serialized Objects and Properties not working with Undo System in custom Editor Window

Hey everyone, I’m having issues with Undos not registering in a custom Editor Window. I’m relatively new to working with Serialized Objects and Serialized Properties, but from what I’ve seen shouldn’t they work with the Undo system automatically. Is my setup wrong or should this be working? Here is a stripped-down version of what my setup looks like:

public class TestEditorWindow : EditorWindow
{
    private SerializedObject m_scriptableObject;
    private SerializedProperty m_testFloatProperty;

    private void LoadScriptableObject()
    {
        m_testFloatProperty = m_scriptableObject.FindProperty("testFloatProperty");
    }

    private void OnGUI()
    {
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(m_testFloatProperty);
        if (EditorGUI.EndChangeCheck())
        {
            m_scriptableObject.ApplyModifiedProperties();
        }
    }
}

Have you tried adding SerializedObject.Update at the beginning of OnGUI() function such as,

private void OnGUI()
    {
        m_scriptableObject.Update();

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(m_testFloatProperty);
        if (EditorGUI.EndChangeCheck())
        {
            m_scriptableObject.ApplyModifiedProperties();
        }
    }

?

You dont need to do the change check, you should call ApplyModifiedProperties at the end each time, it will know if anything has changed.
You also need to call Update at the start, like Slihin100 said.