# GetTransforms(SelectionMode)

> Retrieves the transforms of selected objects.

## Definition

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

```csharp
public static Transform[] GetTransforms(SelectionMode mode)
```

### Parameters

**** (\[SelectionMode]\(/engine/6000.5/script-reference/unityeditor/selectionmode)): Options for refining the selection. Refer to [SelectionMode](/engine/6000.5/script-reference/unityeditor/selectionmode.md)  for the available modes.

### Returns

| Type                                                                      | Description                                                      |
| ------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [Transform\[\]](/engine/6000.5/script-reference/unityengine/transform.md) | The transforms of the selected objects determined by the `mode`. |

### Remarks

Retrieves the transform of the current Editor selection after applying the provided [SelectionMode](/engine/6000.5/script-reference/unityeditor/selectionmode.md) flags. You can use this to iterate through relevant scene objects (such as editable transforms) and perform batch operations on them.

### Examples

```csharp
using UnityEngine;
using UnityEditor;


class CreateParentForTransforms : ScriptableObject
{
    [MenuItem("Example/Create Parent For Selection _p")]
    static void MenuInsertParent()
    {
        Transform[] selection = Selection.GetTransforms(
            SelectionMode.TopLevel | SelectionMode.Editable);
        GameObject newParent = new GameObject("Parent");

        foreach (Transform t in selection)
        {
            t.parent = newParent.transform;
        }
    }

    // Disable the menu if there is nothing selected
    [MenuItem("Example/Create Parent For Selection _p", true)]
    static bool ValidateSelection()
    {
        return Selection.activeGameObject != null;
    }
}
```
