Version: 2023.2
言語: 日本語
public static AssetBundleCreateRequest LoadFromMemoryAsync (byte[] binary);
public static AssetBundleCreateRequest LoadFromMemoryAsync (byte[] binary, uint crc);

パラメーター

binary AssetBundle データを格納するバイトの配列
crc オプションの、非圧縮コンテンツ用 CRC-32 チェックサム。 0 にならない場合、コンテンツは再び比較され、読み込む前にチェックサムが行われ、一致しない場合はエラーが返されます。

戻り値

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

説明

Asynchronously load an AssetBundle from a memory region.

Use this method to load an AssetBundle from an array of bytes asynchronously. This is useful when you have downloaded the data with encryption using UnityWebRequest and have the unencrypted bytes in memory instead of stored in a file.

LoadFromMemory と比較した場合、このバージョンはアセットバンドルの復元をバックグラウンドのスレッドで行い、すぐにはアセットバンドルオブジェクトを作成しません。

The content of the provided byte array is copied to create a temporary AssetBundle file in Memory, and that file is then loaded. Depending on the compression of the original AssetBundle, and the setting for Caching.compressionEnabled, this may also involve converting the content to LZ4 or uncompressed format. See AssetBundles compression for more details.

The following example shows how to use this method. Note, for the sake of keeping the example simple it reads the bytes from disk, which means it has no advantage over calling AssetBundle.LoadFromFileAsync directly.

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

public class Example : MonoBehaviour { IEnumerator LoadFromMemoryAsync(string path) { AssetBundleCreateRequest createRequest = AssetBundle.LoadFromMemoryAsync(File.ReadAllBytes(path)); yield return createRequest; AssetBundle bundle = createRequest.assetBundle; var prefab = bundle.LoadAsset<GameObject>("MyObject"); Instantiate(prefab); } }