# OnSelectionChange()

> Called whenever the selection has changed.

## Definition

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

```csharp
public void OnSelectionChange()
```

### Remarks

![SelectionChange (OnSelectionChange())](/api/media?file=/engine/6000.5/media/images/SelectionChange.png) *Saves the current selection and load it later with a simple click.*

### Examples

```csharp

{code Modules/UIElements/Tests/UIElementsExamples/Assets/EditorWindowCodeExamples/OnSelectionChangeExample.cs}
```
