public static Object[] GetFiltered (Type type, SelectionMode mode);

参数

type仅检索此类型的对象。
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.

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

for (var obj in activeGOs) var activeGO = obj as GameObject; activeGO.SetActive(!activeGO.activeSelf); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961