Version: 2023.1
言語: 日本語
public static AssetBundle LoadFromMemory (byte[] binary);
public static AssetBundle LoadFromMemory (byte[] binary, uint crc);

パラメーター

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

戻り値

AssetBundle アセットバンドルオブジェクトを読み込みますが、失敗した場合は null になります。

説明

Synchronously load an AssetBundle from a memory region.

Use this method to load an AssetBundle from an array of bytes. This is useful when you have downloaded the data with encryption and need to load the AssetBundle from the decrypted bytes.

LoadFromMemoryAsync と比較すると、このバージョンは同時的であり、アセットバンドルオブジェクトの生成が終わるまで返りません。

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class ExampleClass : MonoBehaviour { byte[] MyDecrypt(byte[] binary) { // ...Perform some decryption process here to transform the input... return binary; }

IEnumerator Start() { var uwr = UnityWebRequest.Get("https://myserver/myBundle.unity3d"); yield return uwr.SendWebRequest(); byte[] decryptedBytes = MyDecrypt(uwr.downloadHandler.data); AssetBundle.LoadFromMemory(decryptedBytes); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961