Version: 2023.1
言語: 日本語
public static AssetBundleCreateRequest LoadFromFileAsync (string path);
public static AssetBundleCreateRequest LoadFromFileAsync (string path, uint crc);
public static AssetBundleCreateRequest LoadFromFileAsync (string path, uint crc, ulong offset);

パラメーター

path ディスクにあるファイルのパス
crc オプションの、非圧縮コンテンツ用 CRC-32 チェックサム。 0 にならない場合、コンテンツは再び比較され、読み込む前にチェックサムが行われ、一致しない場合はエラーが返されます。
offset オプションのバイトのオフセット。この値はアセットバンドルのどこから読み込み始めるかを指定します。

戻り値

AssetBundleCreateRequest Asynchronous load request for an AssetBundle. Use assetBundle property to get an AssetBundle once it is loaded.

説明

ディスクから非同期でアセットバンドルを読み込みます。

The function supports bundles of any compression type. In case of LZMA compression, the data will be decompressed to the memory. See AssetBundles compression for more details.

これがアセットバンドルを最速で読み込む方法です。

using UnityEngine;
using System.Collections;
using System.IO;

public class LoadFromFileAsyncExample : MonoBehaviour { IEnumerator Start() { var bundleLoadRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, "myassetBundle")); yield return bundleLoadRequest;

var myLoadedAssetBundle = bundleLoadRequest.assetBundle; if (myLoadedAssetBundle == null) { Debug.Log("Failed to load AssetBundle!"); yield break; }

var assetLoadRequest = myLoadedAssetBundle.LoadAssetAsync<GameObject>("MyObject"); yield return assetLoadRequest;

GameObject prefab = assetLoadRequest.asset as GameObject; Instantiate(prefab);

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