Undo.PerformUndo 执行撤销
static function PerformUndo () : void
Description描述
Perform an Undo operation.
执行一个撤销操作。
This is similar to the user selecting Undo from the Edit menu.
这是类似于用户从编辑菜单选择撤消(Undo...)。
参见: 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 inspectorint savedNumberOfSteps = numberOfSteps + 1;for(int i = 0; i < savedNumberOfSteps; i++) {Undo.PerformUndo();}}}