public static void TestDep01() { try { string main_fest_path = EAssetBundleConst.ManifestPath; //Application.streamingAssetsPath + "/rpg/rpg"; AssetBundle ab = AssetBundle.LoadFromFile(main_fest_path); AssetBundleManifest mainfest = ab.LoadAllAssets()[0] as AssetBundleManifest; foreach (var id in Selection.instanceIDs) { string path = AssetDatabase.GetAssetPath(id); path = EPathHelper.NormalizePath(path); string[] result = path.Split('/'); path = result[result.Length - 1]; string select_name = path.Split('.')[0]; string[] dir = mainfest.GetDirectDependencies(select_name); string[] all = mainfest.GetAllDependencies(select_name); } Resources.UnloadAsset(mainfest); ab.Unload(true); Debug.Log("Error"); } catch (Exception e) { Debug.Log(e.Message); } finally { Resources.UnloadUnusedAssets(); } }
/// <summary> /// 根据外部名字设置Asset的名字 /// </summary> public static void SetAbNameByParam(string filePath, string abName) { string assetPath = EPathHelper.AbsoluteToRelativePathWithAssets(filePath); AssetImporter importer = AssetImporter.GetAtPath(assetPath); if (importer != null) { string assetbundleName = EPathHelper.NormalizePath(abName) + EAssetBundleConst.ASSETBUNDLE_EXTENSION; importer.assetBundleName = assetbundleName; importer.SaveAndReimport(); } else { Debug.LogError("找不到对应的路径的资源:" + filePath); } }