Version: 2019.1
Method group is Obsolete

WWW.LoadFromCacheOrDownload

マニュアルに切り替える
Obsolete public static WWW LoadFromCacheOrDownload (string url, int version);
Obsolete public static WWW LoadFromCacheOrDownload (string url, int version, uint crc);
Obsolete public static WWW LoadFromCacheOrDownload (string url, Hash128 hash, uint crc);
Obsolete public static WWW LoadFromCacheOrDownload (string url, CachedAssetBundle cachedBundle, uint crc);

パラメーター

urlキャッシュされていない場合にアセットバンドルをダウンロードするための URL。'%' は避けなければいけません。
versionアセットバンドルのバージョン。以前に同じ version パラメーターでダウンロードを行っている場合、キャッシュされたデータをロードします。アプリケーションによってインクリメントされたバージョンをリクエストすることによって強制的に url から最新のアセットバンドルをキャッシングすることができます。
hashHash128 which is used as the version of the AssetBundle.
cachedBundleA structure used to download a given version of AssetBundle to a customized cache path.

Analogous to the cachedAssetBundle parameter for UnityWebRequestAssetBundle.GetAssetBundle.</param>
crc非圧縮コンテンツの CRC-32 チェックサム。もしパラメーターが 0 出ない場合はコンテンツをロードする前にチェックサムの比較が行われ一致しない場合はエラーを返します。これはキャッシュされたデータのユーザーによる改竄や改悪、データの破損を避けるために利用されます。CRC が一致しない場合は Unity は再度ダウンロードを試みます。そして CRC がサーバー側で一致しない場合はエラーを返します。今の CRC 値がアセットバンドルに一致しているかはエラー内容から判断することができます。

戻り値

WWW アセットバンドルのロード/ダウンロードが完了したときにデータにアクセスするための WWW インスタンスを返します。

説明

キャッシュからバージョンで指定されたアセットバンドルをロードします。もしアセットバンドルがキャッシュされていない場合は自動的にダウンロードされローカルストレージから復旧できるためにキャッシュに保存されます。

LoadFromCacheOrDownload() はキャッシングを使用するために "new WWW (url)" の代わりに使用するようにしてください。

Cached AssetBundles are uniquely identified solely by the filename and version. All domain and path information in url is ignored by Caching. Since cached AssetBundles are identified by filename instead of the full URL, you can change the directory from where the asset bundle is downloaded at any time. This is useful for pushing out new versions of the game and ensuring that files are not cached incorrectly by the browser or by a CDN.

Usually using the filename of the AssetBundle to generate the cache path is fine. But if there are different AssetBundles with the same last file name, cache conflicts will happen. With CachedAssetBundle, users can use CachedAssetBundle.name to customized the cache path to avoid the cache conflicts. Users can also utilize this to organize the cache data structure.

もし、キャッシュフォルダーに追加できるファイル領域がない場合はキャッシュしようとしているファイルの領域が空くまで LoadFromCacheOrDownload で追加されたもっとも使用頻度の低いアセットバンドルから削除していきます。もし利用可能なファイル領域を確保できない場合(キャッシュされているアセットバンドルをすべて使用している場合や、HDD の要領がいっぱいな場合)は LoadFromCacheOrDownload は "new WWW()" の呼び出しと同じようにメモリ上に展開しストリーミングします。

キャッシュされるデータは、Caching.compressionEnabled を有効にすることにより圧縮形式で保存することができます。

この関数は AssetBundle のアクセスのみに使用することができます。それ以外のタイプやコンテンツはキャッシュできません。

The CRC passed into this function is computed during Asset Bundle build time, see BuildPipeline.BuildAssetBundles.

Note: URL は '%' を避けなければいけません。

using UnityEngine;
using System.Collections;

public class LoadFromCacheOrDownloadExample : MonoBehaviour { IEnumerator Start() { while (!Caching.ready) yield return null;

using (var www = WWW.LoadFromCacheOrDownload("http://myserver.com/myassetBundle.unity3d", 5)) { yield return www; if (!string.IsNullOrEmpty(www.error)) { Debug.Log(www.error); yield return null; } var myLoadedAssetBundle = www.assetBundle;

var asset = myLoadedAssetBundle.mainAsset; } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961