Unity 6.3
0 онлайн 33 гостей 3 в системе
Вход

Undo.RegisterChildrenOrderUndo

Declaration

public static void RegisterChildrenOrderUndo(Object objectToUndo, string name);

Параметры

Параметр Описание
objectToUndo Объект, порядок действий которого должен быть записан в стек отмены.
имя Имя операции отмены.

Описание

Хранит копию порядка дочерей объекта в стеке отмены.

Если выполнить отмену, порядок дочерних объектов будет восстановлен до записанного состояния.

using UnityEngine;
using UnityEditor;

public class UndoExamples { [MenuItem("Undo Examples/RegisterChildrenOrderUndo")] static void Example() { var parent = new GameObject("Parent"); for (int childIndex = 0; childIndex < 5; childIndex += 1) { var child = new GameObject($"Child{childIndex}"); child.transform.parent = parent.transform; }

// Store the states of the parent object. Undo.RegisterChildrenOrderUndo(parent.transform, "Set as last sibling"); parent.transform.GetChild(0).SetAsLastSibling();

// If you choose "Edit->Undo Set as last sibling" from the main menu now, the order of the children will be restored. } }