Undo.RegisterFullObjectHierarchyUndo not working

I have a custom editor that let’s be update the layout of some UI objects, I want to be able to undo this operation if I don’t like it but I can’t get it to record.

My component is set up like so: Main Component (that the custom editor is editing) > Child Content (like the Scroll Rect) > Child Items (children of the content). The Child Items & the Content are what’s being modified.

Currently my code is looking like this:

public override void OnInspectorGUI()
{
	MainComponent main = (MainComponent)target;
	
	//custom inspector stuff
	
	if(GUILayout.Button("Update"))
	{
		Undo.RegisterFullObjectHierarchyUndo(main.Content.gameobject, "Layout Update");
		main.UpdateLayout();
	}
}

This does create an undo step under Edit > Undo. The undo step just doesn’t revert anything. If anyone knows what I’m doing wrong/know something to help I would love to hear it! Ty!

All “Register” methods in the Undo system have to be called right before you apply any changes to your object. You can not group multiple changes into a single undo step if those changes are not applied from the same event (i.e a mouse down / mouse up event).