# ToggleFlags

> Toggles the specified flags on all hierarchy nodes.

## Definition

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

## ToggleFlags(HierarchyNodeFlags)

Toggles the specified flags on all hierarchy nodes.

```csharp
public void ToggleFlags(HierarchyNodeFlags flags)
```

### Parameters

**** (\[HierarchyNodeFlags]\(/engine/6000.5/script-reference/unity/hierarchy/hierarchynodeflags)): The hierarchy node flags.

## ToggleFlags(HierarchyNode, HierarchyNodeFlags)

Toggles the specified flags on the hierarchy node.

```csharp
public void ToggleFlags(in HierarchyNode node, HierarchyNodeFlags flags)
```

### Parameters

**** (\[HierarchyNode]\(/engine/6000.5/script-reference/unity/hierarchy/hierarchynode)): The hierarchy node.**** (\[HierarchyNodeFlags]\(/engine/6000.5/script-reference/unity/hierarchy/hierarchynodeflags)): The hierarchy node flags.

## ToggleFlags(ReadOnlySpan\<HierarchyNode>, HierarchyNodeFlags)

Toggles the specified flags on the hierarchy nodes.

```csharp
public int ToggleFlags(ReadOnlySpan<HierarchyNode> nodes, HierarchyNodeFlags flags)
```

### Parameters

**** (\[ReadOnlySpan\<HierarchyNode>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The hierarchy nodes.**** (\[HierarchyNodeFlags]\(/engine/6000.5/script-reference/unity/hierarchy/hierarchynodeflags)): The hierarchy node flags.

### Returns

| Type                                                       | Description                                       |
| ---------------------------------------------------------- | ------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of nodes that had their flags cleared. |

### Remarks

Null or invalid nodes are ignored.

## ToggleFlags(ReadOnlySpan\<int>, HierarchyNodeFlags)

Toggles the specified flags on the hierarchy node indices.

```csharp
public int ToggleFlags(ReadOnlySpan<int> indices, HierarchyNodeFlags flags)
```

### Parameters

**** (\[ReadOnlySpan\<int>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The hierarchy node indices.**** (\[HierarchyNodeFlags]\(/engine/6000.5/script-reference/unity/hierarchy/hierarchynodeflags)): The hierarchy node flags.

### Returns

| Type                                                       | Description                                       |
| ---------------------------------------------------------- | ------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of nodes that had their flags cleared. |

### Remarks

Invalid node indices are ignored.

## ToggleFlags(HierarchyNode, HierarchyNodeFlags, bool)

Toggles the specified flags on all hierarchy nodes.

> **Warning:**
>
> **Deprecated.** ToggleFlags(node, flags, recurse) with a bool parameter is obsolete, please use ToggleFlags(node, flags) or ToggleFlags(node, flags, direction) instead.

```csharp
public void ToggleFlags(in HierarchyNode node, HierarchyNodeFlags flags, bool recurse)
```

### Parameters

**** (\[HierarchyNode]\(/engine/6000.5/script-reference/unity/hierarchy/hierarchynode)): **** (\[HierarchyNodeFlags]\(/engine/6000.5/script-reference/unity/hierarchy/hierarchynodeflags)): The hierarchy node flags.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)):&#x20;
