Undo.RegisterSceneUndo 注册场景撤销

static function RegisterSceneUndo (name : string) : void

Parameters参数

Description描述

Register the state of the entire scene so the user can later undo back to that state.

记录整个场景以便用户以后恢复。

This is the easiest, most robust, but slowest way to store an Undo operation. Call this method before performing an operation that it should be possible to undo.

这是最简单的、最为强劲,同时也是最慢的方式。

参见:Undo.RegisterUndo.

// Editor Script that lets you change the color of the material of your
// Selected objects to red.
//编辑器脚本,让你改变选择物体的材质颜色到红色

@MenuItem("Example/Mass Set Materials")
static function MassSetAlpha() {
	Undo.RegisterSceneUndo("Mass Set Materials");
	for (var obj : GameObject in Selection.gameObjects) {
		obj.renderer.sharedMaterial.color = Color.red;
	}
}
// If nothing is selected, the menu will be disabled
//如果什么也没有选择,菜单项将被禁用
@MenuItem ("Example/Mass Set Materials", true)
static function ValidateMoveToOrigin () {
	return Selection.activeTransform != null;
}
Page last updated: 2011-5-18