Android上的Unity AssetBundles加载问题

时间:2019-12-26 02:05:12

标签: unity3d

    // No problem
    WWW request = WWW.LoadFromCacheOrDownload(url, version);
    if (request.error == null)
    {
        while (!request.isDone)
        {
            Debug.Log(request.progress);
            loadingSlider.value = request.progress;
            yield return null;
        }
    }

    // Here is the problem on Android
    var myLoadedAssetBundle = bundleLoadRequest.assetBundle;
    if (myLoadedAssetBundle == null)
    {
        Debug.Log("Failed to load AssetBundle!");
        yield break;
    }

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

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

    myLoadedAssetBundle.Unload(false);

以上代码在Android中不起作用,但在编辑器中可以正常工作。

0 个答案:

没有答案