Undo.RegisterCreatedObjectUndo

Cambiar al Manual
public static void RegisterCreatedObjectUndo (Object objectToUndo, string name);

Parámetros

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

Descripción

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.

Note: Object destruction works the same way as it does for Object.Destroy (except for the delay). This means that GameObjects will be destroyed along with all their child GameObjects.

// 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() { // Create GameObject hierarchy. GameObject go = new GameObject("my GameObject"); GameObject child = new GameObject(); go.transform.position = new Vector3(5, 5, 5); child.transform.parent = go.transform;

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