Undo.PerformUndo

static function PerformUndo () : void

Description

Perform an Undo operation.

This is similar to the user selecting Undo from the Edit menu.

See Also: PerformRedo.


Simple Scriptable Wizard that lets you perform an undo several times.

using UnityEngine;
using UnityEditor;

//Performs an Undo the number of times specified.

public class PerformVariousUndo : ScriptableWizard {
public int numberOfSteps = 5;

[MenuItem ("Example/Perform Various Undo %#u")]
static void ExecuteMenu() {
ScriptableWizard.DisplayWizard(
"Perform various Undo at the same time",
typeof(PerformVariousUndo),
"Undo!");
}

void OnWizardCreate() {
// We have to make this in order to make the undo
// dont reset the value entered in the inspector
int savedNumberOfSteps = numberOfSteps + 1;
for(int i = 0; i < savedNumberOfSteps; i++) {
Undo.PerformUndo();
}
}
}