# GetFiltered

> Returns the current selection filtered by type and mode.

## Definition

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

## GetFiltered\<T>(SelectionMode)

Returns the current selection filtered by type and mode.

```csharp
public static T[] GetFiltered<T>(SelectionMode mode)
```

### Parameters

**** (\[SelectionMode]\(/engine/6000.0/script-reference/unityeditor/selectionmode)): Further options to refine the selection.

### Returns

| Type              | Description |
| ----------------- | ----------- |
| [\<T>\[\]](./.md) |             |

### Remarks

For a selected GameObject that has multiple Components of type, only the first one will be included in the results.

If type is a subclass of [Component](/engine/6000.0/script-reference/unityengine/component.md) or [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md) the full SelectionMode is supported.

If type does not subclass from [Component](/engine/6000.0/script-reference/unityengine/component.md) or [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md) (eg. [Mesh](/engine/6000.0/script-reference/unityengine/mesh.md) or [ScriptableObject](/engine/6000.0/script-reference/unityengine/scriptableobject.md)) only [SelectionMode.ExcludePrefab](/engine/6000.0/script-reference/unityeditor/selectionmode/excludeprefab.md) and [SelectionMode.Editable](/engine/6000.0/script-reference/unityeditor/selectionmode/editable.md) are supported.

### Examples

```csharp
using UnityEngine;
using UnityEditor;

class ToggleActive : ScriptableObject
{
    [MenuItem("Example/Toggle Active of Selected %i")]
    static void DoToggle()
    {
        Object[] activeGOs =
            Selection.GetFiltered(
                typeof(GameObject),
                SelectionMode.Editable | SelectionMode.TopLevel);

        foreach (GameObject obj in activeGOs)
        {
            obj.SetActive(!obj.activeSelf);
        }
    }
}
```

## GetFiltered(Type, SelectionMode)

Returns the current selection filtered by type and mode.

```csharp
public static Object[] GetFiltered(Type type, SelectionMode mode)
```

### Parameters

**** (\[Type]\(https\://learn.microsoft.com/dotnet/api/system.type)): Only objects of this type will be retrieved.**** (\[SelectionMode]\(/engine/6000.0/script-reference/unityeditor/selectionmode)): Further options to refine the selection.

### Returns

| Type                                                                | Description |
| ------------------------------------------------------------------- | ----------- |
| [Object\[\]](/engine/6000.0/script-reference/unityengine/object.md) |             |

### Remarks

For a selected GameObject that has multiple Components of type, only the first one will be included in the results.

If type is a subclass of [Component](/engine/6000.0/script-reference/unityengine/component.md) or [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md) the full SelectionMode is supported.

If type does not subclass from [Component](/engine/6000.0/script-reference/unityengine/component.md) or [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md) (eg. [Mesh](/engine/6000.0/script-reference/unityengine/mesh.md) or [ScriptableObject](/engine/6000.0/script-reference/unityengine/scriptableobject.md)) only [SelectionMode.ExcludePrefab](/engine/6000.0/script-reference/unityeditor/selectionmode/excludeprefab.md) and [SelectionMode.Editable](/engine/6000.0/script-reference/unityeditor/selectionmode/editable.md) are supported.

### Examples

```csharp
using UnityEngine;
using UnityEditor;

class ToggleActive : ScriptableObject
{
    [MenuItem("Example/Toggle Active of Selected %i")]
    static void DoToggle()
    {
        Object[] activeGOs =
            Selection.GetFiltered(
                typeof(GameObject),
                SelectionMode.Editable | SelectionMode.TopLevel);

        foreach (GameObject obj in activeGOs)
        {
            obj.SetActive(!obj.activeSelf);
        }
    }
}
```
