您的位置:首页 > 移动开发 > Unity3D

Unity3d获取在Asset中选中的目录、资源 的路径

2015-12-12 02:05 363 查看
[MenuItem("Tools/testselect")]
public static void testselect()
{
UnityEngine.Object[] arr=Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.TopLevel);
Debug.LogError(Application.dataPath.Substring(0,Application.dataPath.LastIndexOf('/'))+"/"+ AssetDatabase.GetAssetPath(arr[0]));
}

如果要遍历目录,修改为

SelectionMode.DeepAssets

这个方法只能对右边选中的文件生效,左边的无效

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: