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

               
[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

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


           

猜你喜欢

转载自blog.csdn.net/qq_44952746/article/details/89708816