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.

PerformUndo

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();
		}
	}
}
最后修改:2011年5月18日 Wednesday 15:25

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。