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.


Suggest a change


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.


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.



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


objectToUndo The object that was created.
name The name of the action to undo. Think "Undo ...." in the main menu.


Register an undo operations for a newly created object.

When the undo is performed the object will be destroyed. All newly created objects that are part of undoable state should be registered with this function.

// Creates a new game object as an operation that can be undone

using UnityEditor; using UnityEngine;

class CreateGameObjectMenu { [MenuItem ("Example/Create GameObject")] static void CreateGameObject () { GameObject go = new GameObject ("my GameObject"); go.transform.position = new Vector3 (5, 5, 5); go.RegisterCreatedObject (go, "Create object"); } }
no example available in C#
no example available in Boo