# GetCurrentGroup()

> Unity automatically groups undo operations by the current group index.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.6/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public static int GetCurrentGroup()
```

### Returns

| Type                                                       | Description                          |
| ---------------------------------------------------------- | ------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the current undo group. |

### Remarks

The current group index is automatically increased on mouse down, clicking on menu items and other operations.

Additional Resources: [Undo.RevertAllDownToGroup](/engine/6000.6/script-reference/unityeditor/undo/revertalldowntogroup.md), [Undo.CollapseUndoOperations](/engine/6000.6/script-reference/unityeditor/undo/collapseundooperations.md).

### Examples

```csharp
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);
    }
}
```
