Version: 2020.2
언어: 한국어
public static Object[] GetFiltered (Type type, SelectionMode mode);

파라미터

type Only objects of this type will be retrieved.
mode Further options to refine the selection.

설명

Returns the current selection filtered by type and mode.

For a selected GameObject that has multiple Components of type, only the first one will be included in the results.
If type is a subclass of Component or GameObject the full SelectionMode is supported.
If type does not subclass from Component or GameObject (eg. Mesh or ScriptableObject) only SelectionMode.ExcludePrefab and SelectionMode.Editable are supported.

using UnityEngine;
using UnityEditor;

class ToggleActive : ScriptableObject { [MenuItem("Example/Toggle Active of Selected %i")] static void DoToggle() { Object[] activeGOs = Selection.GetFiltered( typeof(GameObject), SelectionMode.Editable | SelectionMode.TopLevel);

foreach (GameObject obj in activeGOs) { obj.SetActive(!obj.activeSelf); } } }