[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
这个方法只能对右边选中的文件生效,左边的无效