Selection Class  

Scripting > Editor Classes > Selection

Access to the selection in the editor.

Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.

Class Variables
transforms

Returns the top level selection, excluding prefabs.

activeTransform

Returns the active transform. (The one shown in the inspector)

gameObjects

Returns the actual game object selection. Includes prefabs, non-modifyable objects.

activeGameObject

Returns the active game object. (The one shown in the inspector)

activeObject

Returns the actual object selection. Includes prefabs, non-modifyable objects.

objects

The actual unfiltered selection.

Class Functions
GetTransforms

Allows for fine grained control of the selection type using the SelectionMode bitmask.

GetFiltered

Returns the current selection filtered by type and mode.