Selection.objects Manual     Reference     Scripting  
Scripting > Editor Classes > Selection
Selection.objects

static var objects : Object[]

Description

The actual unfiltered selection from the Scene.

Only objects from the Scene or Hierarchy will be returned, not from the Project View. You can also assign objects to the selection.

See Also: Selection.instanceIDs.


Scriptable Wizard that lets you select GameObjects by their tag.

// C# Example
// Select objects based on their tags

using UnityEngine;
using UnityEditor;

public class SelectAllOfTag : ScriptableWizard {
public string tagName = "ExampleTag";

[MenuItem ("Example/Select All of Tag...")]
public static void SelectAllOfTagWizard() {
ScriptableWizard.DisplayWizard(
"Select All of Tag...",
typeof(SelectAllOfTag),
"Make Selection");
}

void OnWizardCreate() {
GameObject[] gos = GameObject.FindGameObjectsWithTag(tagName);
Selection.objects = gos;
}
}