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) == false) { _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); }
public AssetBundleInfo LoadSync(string path) { string newPath = path.Replace("/", "\\"); #if _AB_MODE_ AssetBundleLoader loader = this.CreateLoader(HashUtil.Get(newPath.ToLower()) + ".ab", newPath); #else AssetBundleLoader loader = this.CreateLoader(newPath); #endif return(LoadBundleSync(loader)); }
public AssetTarget(Object o, FileInfo file, string assetPath) { this.asset = o; this.file = file; this.assetPath = assetPath; this.bundleShortName = file.Name.ToLower(); this.bundleName = HashUtil.Get(AssetBundleUtils.ConvertToABName(assetPath)) + ".ab"; this.bundleSavePath = Path.Combine(AssetBundleUtils.pathResolver.BundleSavePath, bundleName); _isFileChanged = true; _metaHash = "0"; }
public AssetBundleInfo GetBundleInfo(string key) { key = key.ToLower(); #if _AB_MODE_ key = HashUtil.Get(key) + ".ab"; #endif var e = _loadedAssetBundle.GetEnumerator(); while (e.MoveNext()) { AssetBundleInfo abi = e.Current.Value; if (abi.bundleName == key) { return(abi); } } return(null); }
/// <summary> /// 通过一个路径加载ab /// </summary> /// <param name="path">路径</param> /// <param name="prority">优先级</param> /// <param name="handler">回调</param> /// <returns></returns> public AssetBundleLoader LoadAsync(string path, int prority, LoadAssetCompleteHandler handler = null) { string newPath = path.Replace("/", "\\"); #if _AB_MODE_ AssetBundleLoader loader = this.CreateLoader(HashUtil.Get(newPath.ToLower()) + ".ab", newPath); #else AssetBundleLoader loader = this.CreateLoader(newPath); #endif loader.prority = prority; loader.onComplete += handler; _isCurrentLoading = true; _nonCompleteLoaderSet.Add(loader); _thisTimeLoaderSet.Add(loader); return(loader); }