public IEnumerator CopyAssets(string[] keys) { foreach (string item in keys) { yield return(StartCoroutine(WebUtil.Download($"{"file:///"}{PathUtil.GetPath(PathType.StreamingAssetsPath, "Res", PathUtil.GetPlatformForAssetBundle())}/{item}", (byte[] bytes) => { FileUtil.SaveAsset(PathUtil.GetPath(PathType.PersistentDataPath, "Res", PathUtil.GetPlatformForAssetBundle()), item, bytes); currentCopyCount += 1; Message?.Invoke($"初始化资源 {currentCopyCount} / {copyCount}"); CopyProgress?.Invoke(currentCopyCount, copyCount); }))); } //更新资源 UpdateAssets(string.Empty); }
public void InitAssets(Action <string> message = null, Action <int, int> copyProgress = null, Action <int, int> downloadProgress = null, Action <int, int> checkProgress = null, Action complete = null, Action <DownloadData, string> error = null) { Message = message; CopyProgress = copyProgress; DownloadProgress = downloadProgress; CheckProgress = checkProgress; Complete = complete; Error = error; if (File.Exists($"{PathUtil.GetPath(PathType.PersistentDataPath, "Res", PathUtil.GetPlatformForAssetBundle())}/AssetBundleConfig.json")) { byte[] bytes = FileUtil.GetAsset($"{PathUtil.GetPath(PathType.PersistentDataPath, "Res", PathUtil.GetPlatformForAssetBundle())}/AssetBundleConfig.json"); localAssetBundleConfig = JsonUtil.ToObject <AssetBundleConfig>(bytes.GetString()); //更新资源 UpdateAssets(string.Empty); return; } else { StartCoroutine(WebUtil.Download($"{"file:///"}{PathUtil.GetPath(PathType.StreamingAssetsPath, "Res", PathUtil.GetPlatformForAssetBundle())}/AssetBundleConfig.json", InitAssets, UpdateAssets)); } }
public void LoadAudio(string audio, AudioType type, Action <AudioClip> callback) { StartCoroutine(WebUtil.Download(audio, type, callback)); }