Search Unity

Question I want to download assets in bulk (addressable, DownloadDependenciesAsync)

Discussion in 'Asset Bundles' started by MinChangGi, Aug 23, 2022.

  1. MinChangGi

    MinChangGi

    Joined:
    Feb 24, 2020
    Posts:
    1
    I want to use [Addressable] to download assets all at once.
    But it doesn't work.

    When calling with [Addressable] set in the scene, the dependencies were successfully acquired.
    However, if you specify [Addressable] for individual assets and retrieve them, the dependencies are lost.

    You can call assets.
    However, even if the same group and the same label are specified, the dependencies are not read.

    (Failure example)
    var op1 = Addressables.LoadAssetAsync<GameObject>("TestCube");
    GameObject prefabObj = op1.WaitForCompletion();
    GameObject objInstance = Instantiate(prefabObj, new Vector3(0, 0, 0), Quaternion.identity);
    Addressables.Release(op1);

    (Example of expected behavior)
    var op1 = Addressables.LoadAssetAsync<GameObject>("TestCube");
    var op2 = Addressables.LoadAssetAsync<Material>("TestCubeMat");
    GameObject prefabObj = op1.WaitForCompletion();
    Material mat = op2.WaitForCompletion();
    GameObject objInstance = Instantiate(prefabObj, new Vector3(0, 0, 0), Quaternion.identity);
    objInstance.GetComponent<Renderer>().material = mat;
    Addressables.Release(op1);
    Addressables.Release(op2);

    If you use DownloadDependenciesAsync, it seems that you can download assets in bulk in advance.

    var downloadDependenciesHandle = Addressables.DownloadDependenciesAsync("TestCubeDep", true);
    downloadDependenciesHandle.Completed += (res) =>
    {
    Debug.Log("TestCubeDep : OK");
    };

    However, even if you try to display the asset after checking the log, the dependencies cannot be obtained in the above failure example.
    How can I download assets in bulk?

    Please help me, thank you.