Version: 2018.2

Undo.RegisterCompleteObjectUndo

マニュアルに切り替える
public static void RegisterCompleteObjectUndo (Object objectToUndo, string name);

パラメーター

objectToUndoUndo される必要のある状態が変わっているオブジェクトの配列
nameUndo 名

説明

Undo スタック上のオブジェクトの状態の複製を保存します。

If the undo is performed, any changes made to the object after this function is called will be undone, and the object will be restored to the recorded state.

Transform parent change, AddComponent, and object destruction can not be restored with this function, for that you should use the dedicated functions. See Undo.SetTransformParent, Undo.AddComponent, Undo.DestroyObjectImmediate.

If the object is part of the current scene (e.g. a game object in the Hierarchy or a component attached to such game object), calling this function will immediately mark the scene as modified, even if you don't actually change the states of the object afterwards.

using UnityEngine;
using UnityEditor;

public class UndoExamples { [MenuItem("Undo Examples/RegisterCompleteObjectUndo")] static void Example() { GameObject player = new GameObject("Player");

// Store the states of the player object. Undo.RegisterCompleteObjectUndo(player, "Player name change");

player.name = "New Player";

// If you choose "Edit->Undo Player name change" from the main menu now, the name of the object will be restored to "Player". } }

public static void RegisterCompleteObjectUndo (Object[] objectsToUndo, string name);

パラメーター

objectsToUndoUndo される必要のある状態が変わっているオブジェクトの配列
nameUndo 名

説明

これは最初のオーバーロードを複数回呼び出すのと同義で、Undo 操作が1つだけこの関数のために生成されるという事実を省きます。

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961