# ToggleSelection

> Toggles the selection state of the current selection.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Hierarchy](/engine/6000.7/script-reference/unity/hierarchy.md)
* **Assembly:** UnityEngine.HierarchyModule

## ToggleSelection()

Toggles the selection state of the current selection.

```csharp
public void ToggleSelection()
```

## ToggleSelection(bool)

Toggles the selection state of the current selection.

```csharp
public void ToggleSelection(bool exposedOnly)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): When `true`, selects only exposed nodes (excludes hidden or unreachable nodes). When `false`, selects all nodes regardless of exposure state. **Note:** Nodes outside the viewport are still selected if they are exposed.
