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.

activeInstanceID

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

objects

The actual unfiltered selection from the Scene.

instanceIDs

The actual unfiltered selection from the Scene returned as instance ids instead of objects.

Class Functions
Contains

Returns whether an object is contained in the current selection.

GetTransforms

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

GetFiltered

Returns the current selection filtered by type and mode.