Determine difference between Undo and Redo operations

Hi all,

I’m using Undo.RecordObject to undo changes to a mesh and need to do a clean up after the user presses Ctrl-Z but can’t determine the difference between this and Ctrl-Y.

The following code tells me that something happened but I can’t find any extra info.

if (Event.current.type == EventType.ValidateCommand)
{
    switch (Event.current.commandName)
    {
        case "UndoRedoPerformed":
            Debug.Log ("What actually happened?");
        break;
    }
}

Thanks in advance for any help.

Unity’s Undo is designed to be automatic. As long as you properly record all of the creation/parenting/changes, then Unity will handle the Undo and the Redo for you automatically. Catching the UndoRedoPerformed event using the string command name is pretty far into undocumented/unsupported territory, and should really only be used if you need to do something like reset a UI on Undo or Redo. I’m not aware of any way to get the list of changes for that Undo or Redo.