# ForEach

> Executes the given Action for each Quality Level configured in QualitySettings.

## Definition

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

## ForEach(Action)

Executes the given [Action](/engine/6000.5/script-reference/unity/android/gradle/manifest/action.md) for each Quality Level configured in [QualitySettings](/engine/6000.5/script-reference/unityengine/qualitysettings.md).

```csharp
public static void ForEach(Action callback)
```

### Parameters

**** (\[Action]\(https\://learn.microsoft.com/dotnet/api/system.action)): The callback to execute for each level.

### Remarks

This method iterates through the configured quality levels and invokes the callback for every one. When this method returns, the original quality level is restored.

The following example adds a helper menu item that sets the Vsync Count setting on every quality level to "Don't Sync".

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class ForEachQualityLevelExample
{
    [MenuItem("Tools/Disable Vsync for All Quality Levels")]
    static void DisableVsync()
    {
        QualitySettings.ForEach(() =>
        {
            QualitySettings.vSyncCount = 0;
        });
    }
}
```

## ForEach(Action\<int, string>)

Executes the given [Action](/engine/6000.5/script-reference/unity/android/gradle/manifest/action.md) for each Quality Level configured in [QualitySettings](/engine/6000.5/script-reference/unityengine/qualitysettings.md).

```csharp
public static void ForEach(Action<int, string> callback)
```

### Parameters

**** (\[Action\<int, string>]\(https\://learn.microsoft.com/dotnet/api/system.action)): The callback to execute for each level.

### Remarks

This method iterates through the configured quality levels and invokes the callback for every one. When this method returns, the original quality level is restored.

The following example adds a helper menu item that sets the Vsync Count setting on every quality level to "Don't Sync".

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class ForEachQualityLevelExample
{
    [MenuItem("Tools/Disable Vsync for All Quality Levels")]
    static void DisableVsync()
    {
        QualitySettings.ForEach(() =>
        {
            QualitySettings.vSyncCount = 0;
        });
    }
}
```
