在我的应用程序中,用户可以走路,这会改变球体上的纹理 . 为了节省ram我想要动态加载,所以我计算任何一对图像之间的距离,只加载那些接近的图像 .

我想在后台加载,但目前每次加载都会冻结游戏 . 我已经尝试提前加载所有资产包,只在运行时加载资产 - 仍然冻结 . (冻结在Android BTW上,而不是在comp上)

对于我的代码,我使用RemoteFiles数组,这是一个用于加载assetsbundles的类 . 每个AssetBundle都有一个纹理 .

我的代码目前是这样的:

IEnumerator loadTextures(){

    //Load assetbundles - texts is the array of textures
    for (int j = 0; j < texts.Length; j++) {
        yield return StartCoroutine (PicManager.Instance.remoteFiles[j].LoadLocalBundle ());
    }

    //dynamic loading
    while (true) {

        int index = Picture the user is currently on;

        for (int j = 0; j < texts.Length; j++) {

            //if transitions[i,j] is true, the images are close enough and and j needs to be downloaded
            if (transitions [index, j]) {

                //if the texture is not loaded, load it
                if (texts [j] == null) {

                    AssetBundleRequest request = null;
                    request = PicManager.Instance.remoteFiles [j].LocalBundle.LoadAssetAsync (j + ".jpg", typeof(Texture));
                    yield return request;                           
                    Texture cube = request.asset as Texture;
                    PicManager.Instance.texts [j] = cube;
                    //PicManager.Instance.remoteFiles [j].UnloadLocalBundle ();
                }

            } else {

                //if the texture is loaded, unload it
                if (texts [j] != null) {
                    Resources.UnloadAsset (texts [j]);
                    texts [j] = null;
                }

            }
        }


        yield return new WaitForSeconds(0.05f);

    }
}

我做错了什么,或者在后台加载纹理不可能?

谢谢!