Provides access to the selection in the Editor.
The selection API tracks Object-based selections. Object-based selections are where the inspector window displays the selected object or objects.
If you have an Editor window or an Editor tool that has custom selections, and you want them to be recorded in the Editor's selection history use Selection.RegisterCustomHandler and Selection.SetCustomSelection. In the Editor, you can use the Previous Selection and Next Selection buttons in the main toolbar to cycle through your selection history.
| Property | Description |
|---|---|
| activeContext | Returns the current context object, as was set via SetActiveObjectWithContext. |
| activeEntityId | Returns the entityId of the actual object selection. Includes Prefabs, non-modifiable objects. |
| activeGameObject | Returns the active game object. (The one shown in the inspector). |
| activeObject | Returns the actual object selection. Includes Prefabs, non-modifiable objects. |
| activeTransform | Returns the active transform. (The one shown in the inspector). |
| assetGUIDs | Returns the guids of the selected assets. |
| count | Returns the number of objects in the Selection. |
| entityIds | The actual unfiltered selection from the Scene returned as entityIds instead of objects. |
| gameObjects | Returns the actual game object selection. Includes Prefabs, non-modifiable objects. |
| objects | The actual unfiltered selection from the Scene. |
| selectionChanged | Delegate callback triggered when currently active/selected item has changed. |
| transforms | Returns the top level selection, excluding Prefabs. |
| Method | Description |
|---|---|
| Contains | Returns whether an object is contained in the current selection. |
| GetFiltered | Returns the current selection filtered by type and mode. |
| GetTransforms | Retrieves the transforms of selected objects. |
| RegisterCustomHandler | Registers a handler for custom non-Object based selection in selection history. |
| SetActiveObjectWithContext | Selects an object with a context. |
| SetCustomSelection | Records a custom selection in the Editor's selection history. |
| UnregisterCustomHandler | Unregisters the current handler and validator for the given key |