Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

Selection

class in UnityEditor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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.

Static Properties

Property Description
activeContextReturns the current context object, as was set via SetActiveObjectWithContext.
activeEntityIdReturns the entityId of the actual object selection. Includes Prefabs, non-modifiable objects.
activeGameObjectReturns the active game object. (The one shown in the inspector).
activeObjectReturns the actual object selection. Includes Prefabs, non-modifiable objects.
activeTransformReturns the active transform. (The one shown in the inspector).
assetGUIDsReturns the guids of the selected assets.
countReturns the number of objects in the Selection.
entityIdsThe actual unfiltered selection from the Scene returned as entityIds instead of objects.
gameObjectsReturns the actual game object selection. Includes Prefabs, non-modifiable objects.
objectsThe actual unfiltered selection from the Scene.
selectionChangedDelegate callback triggered when currently active/selected item has changed.
transformsReturns the top level selection, excluding Prefabs.

Static Methods

Method Description
ContainsReturns whether an object is contained in the current selection.
GetFilteredReturns the current selection filtered by type and mode.
GetTransformsRetrieves the transforms of selected objects.
RegisterCustomHandlerRegisters a handler for custom non-Object based selection in selection history.
SetActiveObjectWithContextSelects an object with a context.
SetCustomSelectionRecords a custom selection in the Editor's selection history.
UnregisterCustomHandlerUnregisters the current handler and validator for the given key