unity编辑器选中_Unity Selection编辑器类

Selection

Selection是编辑器类,需要放在在Assets/Editor目录下。

SelectionMode

dbe17448c98e

SelectionMode

//编辑器方法

[MenuItem("Assets/SelectionMode/SelectionMode.TopLevel")]

public static void SelectUnfiltered()

{

UnityEngine.Object[] arr = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.TopLevel);

for (int index = 0; index < arr.Length; index++)

{

string filePath = AssetDatabase.GetAssetPath(arr[index]);

Debug.Log("FilePath" + filePath);

}

}

SelectionMode.Unfiltered

选中一个:返回选中的一个路径;

选中多个:返回选中的多个路径。

SelectionMode.TopLevel

当选中一个:跟SelectionMode.Unfiltered结果一致;

当一次选中多个:返回第一个选中的一个路径。

SelectionMode.Deep

返回所有包括文件夹和预制件的集合

SelectionMode.ExcludePrefab

返回忽略预制件项

SelectionMode.Editable

将从导入的fbx文件中过滤生成的预制件,而不是用户创建的预制件

SelectionMode.Assets

SelectionMode.DeepAssets

收集所有包括文件夹,Assets,子文件夹。

Selection.GetFiltered

static function GetFiltered (type : Type, mode : SelectionMode) : Object[]

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.

如果Type是Component或者GameObject的子类,全部selectionMode都可以支持;

否则SelectionMode.ExcludePrefab and SelectionMode.Editable 类型才支持;

默认是:SelectionMode.TopLevel | SelectionMode.ExcludePrefab | SelectionMode.Editable.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值