Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Undo.RecordObject

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function RecordObject(objectToUndo: Object, name: string): void;
public static void RecordObject(Object objectToUndo, string name);
public static def RecordObject(objectToUndo as Object, name as string) as void

Description

Records any changes done on the object after the RecordObject function.

Almost all property changes can be recorded with this function. The transform parent, AddComponent, object destruction can not be recorded with this function, for that you should use the dedicated functions.

Internally this will create a temporary copy of the objects state and at the end of the frame Unity will diff the state and thus detect what exactly has changed. The changed properties are then recorded on the undo stack. If nothing has actually changed (Binary exact comparison is used for all properties), no undo operation will be stored on the stack.

        Undo.RecordObject (Selection.activeTransform, "Edit Transform");
Selection.activeTransform.position = Vector3(0, 0, 0);
no example available in C#
no example available in Boo
	// Editor Script Side
	// Create a position Handle and make the target always look at the position handle.
	// This is an editor Script, this should go inside the Editor Folder.

[CustomEditor (typeof(LookAtPoint))] class SnapshotTargetEx extends Editor {

void OnSceneGUI () { LookAtPoint lookAtScript;

EditorGUI.BeginChangeCheck (); Vector3 pos = Handles.PositionHandle(target.lookAtPoint, Quaternion.identity); if (EditorGUI.EndChangeCheck ()) { Undo.RecordObject ("Move point"); target.lookAtPoint = pos;

// Make sure to call SetDirty otherwise the inspector will not know that the script properties were modified EditorUtility.SetDirty (target); } } }