Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Undo.RegisterFullObjectHierarchyUndo

フィードバック

ありがとうございます

この度はドキュメントの品質向上のためにご意見・ご要望をお寄せいただき、誠にありがとうございます。頂いた内容をドキュメントチームで確認し、必要に応じて修正を致します。

閉じる

送信に失敗しました

なんらかのエラーが発生したため送信が出来ませんでした。しばらく経ってから<a>もう一度送信</a>してください。ドキュメントの品質向上のために時間を割いて頂き誠にありがとうございます。

閉じる

キャンセル

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

パラメーター

objectToUndo Undo される必要のある状態が変わっているオブジェクトのヒエラルキーを決定するのに使用するオブジェクト
name Undo 名

説明

オブジェクトのヒエラルキーの状態を Undo スタック上にコピーします。

This function works similarly to Undo.RegisterCompleteObjectUndo. The key difference is that instead of copying the states of a single object, this function stores the states of a hierarchy of objects. Depending on the type of objectToUndo, the hierarchy is determined differently:

* If objectToUndo is a game object, the hierarchy will contain (a) objectToUndo itself and its child game objects; (b) the components attached to these game objects.

* If objectToUndo is a component attached to an existing game object, the hierarchy will contain the game object and all of its components, including objectToUndo. Child game objects are NOT involved in this case.

* In all other cases, the hierarchy will only contain objectToUndo itself. It's then equivalent to calling Undo.RegisterCompleteObjectUndo with the same parameters.

If the undo is performed, any changes made to the objects in the above described hierarchy after this function is called will be undone, and the objects 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 any object involved is part of the current scene (e.g. a game object in the Hierarchy window 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 objects afterwards.


        
using UnityEngine;
using UnityEditor;

public class UndoExamples { [MenuItem("Undo Examples/RegisterFullObjectHierarchyUndo 1")] static void Example1 () { GameObject root = new GameObject("Root"); MeshRenderer rootComponent1 = root.AddComponent<MeshRenderer>(); MeshCollider rootComponent2 = root.AddComponent<MeshCollider>();

GameObject child = new GameObject("Child"); child.transform.parent = root.transform; MeshRenderer childComponent1 = child.AddComponent<MeshRenderer>(); MeshCollider childComponent2 = child.AddComponent<MeshCollider>();

// Store the states of 'root' and its children. Undo.RegisterFullObjectHierarchyUndo(root, "full object hierarchy change");

root.name = "New Root"; child.name = "New Child";

rootComponent1.enabled = false; rootComponent2.enabled = false;

childComponent1.enabled = false; childComponent2.enabled = false;

// If you choose "Edit->Undo full object hierarchy change" from the main menu now, // the states of both game objects and their components will be restored to what they were right before calling Undo.RegisterFullObjectHierarchyUndo. } }

        
using UnityEngine;
using UnityEditor;

public class UndoExamples { [MenuItem("Undo Examples/RegisterFullObjectHierarchyUndo 2")] static void Example2 () { GameObject root = new GameObject("Root"); MeshRenderer rootComponent1 = root.AddComponent<MeshRenderer>(); MeshCollider rootComponent2 = root.AddComponent<MeshCollider>();

GameObject child = new GameObject("Child"); child.transform.parent = root.transform; MeshRenderer childComponent1 = child.AddComponent<MeshRenderer>(); MeshCollider childComponent2 = child.AddComponent<MeshCollider>();

// Store the states of 'root' and all of its components. Undo.RegisterFullObjectHierarchyUndo(rootComponent1, "full object hierarchy change");

root.name = "New Root"; child.name = "New Child";

rootComponent1.enabled = false; rootComponent2.enabled = false;

childComponent1.enabled = false; childComponent2.enabled = false;

// If you choose "Edit->Undo full object hierarchy change" from the main menu now, // the states of 'root' and all of its components will be restored to what they were right before calling Undo.RegisterFullObjectHierarchyUndo, // but changes made to 'child' and its components won't be restored. } }

public static function RegisterFullObjectHierarchyUndo(objectToUndo: Object): void;
public static void RegisterFullObjectHierarchyUndo(Object objectToUndo);

パラメーター

説明

このオーバーロードは非推奨です。代わりに Undo.RegisterFullObjectHierarchyUndo(Object, string) を使用してください。