/// <summary> /// 根据Asset的上层目录设置Asset的名字 /// </summary> public static void SetAbNameByDirectory(string assetPath) { AssetImporter importer = AssetImporter.GetAtPath(assetPath); if (importer != null) { // 剔除Assets/ string removeAssetPath = EPathHelper.AbsoluteToRelativePathRemoveAssets(assetPath); // 得到文件的目录 string str = EPathHelper.GetDirectory(removeAssetPath); importer.assetBundleName = str + EAssetBundleConst.ASSETBUNDLE_EXTENSION; importer.SaveAndReimport(); } else { Debug.LogError("找不到对应的路径的资源:" + assetPath); } }