Version: 2023.1
언어: 한국어

Undo.SetCurrentGroupName

매뉴얼로 전환
public static void SetCurrentGroupName (string name);

파라미터

name New name of the current undo group.

설명

Set the name of the current undo group.

Setting a name manually will override an implicitly generated name for the group.

See Also: Undo.GetCurrentGroupName.

using UnityEditor;
using UnityEngine;

public class ResetPositionForSelectedGameObjectsExample : MonoBehaviour
{
    [MenuItem("MyMenu/Reset Positions of Selected GameObjects")]
    static void ResetPositionForSelectedGameObjects()
    {
        Undo.SetCurrentGroupName("Zero out selected gameObjects");
        int group = Undo.GetCurrentGroup();

        Undo.RecordObjects(Selection.transforms, "transform selected objects");

        foreach (Transform t in Selection.transforms)
        {
            t.position = Vector3.zero;
        }

        Undo.CollapseUndoOperations(group);
    }
}