Version: 5.3 (switch to 5.4b)
ЯзыкEnglish
  • C#
  • JS

Язык программирования

Выберите подходящий для вас язык программирования. Все примеры кода будут представлены на выбранном языке.

Undo.RegisterCompleteObjectUndo

Предложить изменения

Успех!

Благодарим вас за то, что вы помогаете нам улучшить качество документации по Unity. Однако, мы не можем принять любой перевод. Мы проверяем каждый предложенный вами вариант перевода и принимаем его только если он соответствует оригиналу.

Закрыть

Ошибка внесения изменений

По определённым причинам предложенный вами перевод не может быть принят. Пожалуйста <a>попробуйте снова</a> через пару минут. И выражаем вам свою благодарность за то, что вы уделяете время, чтобы улучшить документацию по Unity.

Закрыть

Отменить

Руководство
public static function RegisterCompleteObjectUndo(objectToUndo: Object, name: string): void;
public static void RegisterCompleteObjectUndo(Object objectToUndo, string name);

Параметры

objectToUndo The object whose state changes need to be undone.
name The name of the undo operation.

Описание

Stores a copy of the object states on the undo stack.

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 function RegisterCompleteObjectUndo(objectsToUndo: Object[], name: string): void;
public static void RegisterCompleteObjectUndo(Object[] objectsToUndo, string name);

Параметры

objectsToUndo An array of objects whose state changes need to be undone.
name The name of the undo operation.

Описание

This is equivalent to calling the first overload mutiple times, save for the fact that only one undo operation will be generated for this one.