Version: 2022.1

Undo.RegisterChildrenOrderUndo

切换到手册
public static void RegisterChildrenOrderUndo (Object objectToUndo, string name);

参数

objectToUndo The object whose child order should be recorded on the undo stack.
name 撤销操作的名称。

描述

Stores a copy of the order of the object's children on the undo stack.

If the undo is performed, the order of the object's children will be restored to the recorded state.

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. } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961