加载 AssetBundle 的四种方法

1、AssetBundle.LoadFromMemoryAsync(byte[] binary, uint crc = 0);

   返回AssetBundleCreateRequest.Use assetBundle property to get an AssetBundle once it is loaded.

  Compared to LoadFromMemory, this version will perform AssetBundle decompression on a background thread, and will not create the AssetBundle object immediately.

 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);

    }
View Code

相关文章: