public AssetBundleTarget(string name, string dir, AssetBundleNode node, string main, ref List <string> assets) { this.node = node; this.assets = assets; mainAsset = main; if (assets.Count == 1) { mainAsset = assets[0]; } if (string.IsNullOrEmpty(mainAsset)) { // Resources下的Node不允许目录重复,非Resources下的允许,所以此处要做处理防止bundleName重复 bundleName = HashUtil.Get(AssetBundleUtils.ConvertToABName(dir.Contains("/Resources/") || dir.EndsWith("/Resources") ? dir : dir + node.ID)); bundleShortName = name.ToLower(); } else { string pathWithNoExt = mainAsset.Substring(0, mainAsset.LastIndexOf('.')); bundleName = HashUtil.Get(AssetBundleUtils.ConvertToABName(pathWithNoExt)); bundleShortName = Path.GetFileName(mainAsset).ToLower(); } _isFileChanged = true; _metaHash = "0"; }
private AssetBundleInfo GetBundleInfo(string path, bool isLevel = false) { AssetBundleData abd = null; // 获取该资源对应的assetbundle名字 string fullPath = isLevel ? string.Format("Assets/Art/Scenes/{0}/{1}", path, path) : string.Format("Assets/Resources/{0}", path); string bundleName = null; do { bundleName = HashUtil.Get(AssetBundleUtils.ConvertToABName(fullPath)); abd = _dependInfoReader.GetAssetBundleData(bundleName); if (abd != null) { break; } fullPath = fullPath.Substring(0, fullPath.LastIndexOf('/')); } while (fullPath.Contains("/") && !isLevel); if (abd == null) { Debug.LogError(string.Format("Failed to load assetbundle step1: {0}", path)); return(null); } return(LoadAssetBundle(abd)); }
public static string GetFileHash(string path, bool force = false) { string _hexStr = null; if (_fileHashCache.ContainsKey(path) && !force) { _hexStr = _fileHashCache[path]; } else if (!File.Exists(path)) { _hexStr = "FileNotExists"; } else { FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); _hexStr = HashUtil.Get(fs); _fileHashCache[path] = _hexStr; fs.Close(); } return(_hexStr); }