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!