# ToggleFlags

> Toggles the specified flags on all hierarchy nodes.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Hierarchy](/engine/6000.7/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.7/script-reference/unity/hierarchy/hierarchynodeflags)): The flags to toggle on all hierarchy nodes in the view model.

## ToggleFlags(HierarchyNode, HierarchyNodeFlags)

Toggles the specified flags on the hierarchy node.

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

### Parameters

**** (\[HierarchyNode]\(/engine/6000.7/script-reference/unity/hierarchy/hierarchynode)): The hierarchy node to toggle the flags on.**** (\[HierarchyNodeFlags]\(/engine/6000.7/script-reference/unity/hierarchy/hierarchynodeflags)): The flags to toggle on the hierarchy node.

## 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 to toggle the flags on.**** (\[HierarchyNodeFlags]\(/engine/6000.7/script-reference/unity/hierarchy/hierarchynodeflags)): The flags to toggle on the specified hierarchy nodes.

### Returns

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

### 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 to toggle the flags on.**** (\[HierarchyNodeFlags]\(/engine/6000.7/script-reference/unity/hierarchy/hierarchynodeflags)): The flags to toggle on the hierarchy nodes at the specified indices.

### Returns

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

### Remarks

Invalid node indices are ignored.
