/// <summary></summary> /// <param name="strPath"></param> /// <param name="OnFail"></param> /// <returns></returns> public string ToRecsourcsPath(string strPath, Action <string> OnFail = null) { if (string.IsNullOrEmpty(strPath)) { return(null); } if (FileTool.isFileUrl(strPath)) { strPath = FileTool.PhysicalUrlToFullPhysicalPath(strPath); } if (FileTool.IsFullPath(strPath)) { strPath = FileTool.PhysccalFullPathToAssetPath(strPath); strPath = FileTool.AssetPathToAssetCutPath(strPath); } return(FileTool.GetFileNameWithoutExtension(strPath)); }
/// <summary>设置指定文件的Bundle名称</summary> /// <param name="strRecsFullFilePath">指定文件路径(完整路径)</param> /// <param name="ContainDependences"></param> public static void SetTargetFileBundleName(string strRecsFullFilePath, bool ContainDependences = true) { if (string.IsNullOrEmpty(strRecsFullFilePath) || !File.Exists(strRecsFullFilePath) || strRecsFullFilePath.EndsWith(".meta")) { return; } strRecsFullFilePath = strRecsFullFilePath.Trim(); string strPathRelative = FileTool.PhysccalFullPathToAssetPath(strRecsFullFilePath); //string strPathRelative = "Assets" + strRecsFullFilePath.Substring(Application.dataPath.Length); AssetImporter aiMain = AssetImporter.GetAtPath(strPathRelative); if (aiMain == null) { return; } string strNameBundle = FileTool.RemovePathExtension(strRecsFullFilePath).Substring(Application.dataPath.Length + 1).Replace("\\", "/").ToLower(); //清除之前可能已经存在的BundleName AssetDatabase.RemoveAssetBundleName(strNameBundle, true); aiMain.assetBundleName = strNameBundle; //处理依赖项 if (ContainDependences) { string[] arrDenpen = AssetDatabase.GetDependencies(strPathRelative); for (int i = 0; i < arrDenpen.Length; i++) { if (arrDenpen[i].EndsWith(".cs") || arrDenpen[i].Contains(strPathRelative)) { continue; } SetTargetFileBundleName(string.Format("{0}/{1}", Application.dataPath, FileTool.AssetPathToAssetCutPath(arrDenpen[i])), false); } } }
void AssetPathToAssetCutPath() { strAssetCutPath = FileTool.AssetPathToAssetCutPath(strAssetPath); }